[Solved] how can create Unique Constraint with multi column with entityframework

In your EntityTypeConfiguration you can do something like this: Property(m => m.CompanyId) .HasColumnAnnotation(“Index”, new IndexAnnotation(new IndexAttribute(“IX_YourUniqueIndexName”, 1) { IsUnique = true })); Property(m => m.Code) .HasColumnAnnotation(“Index”, new IndexAnnotation(new IndexAttribute(“IX_YourUniqueIndexName”, 2) { IsUnique = true })); This will create a unique index on those 2 columns. Make sure you use the same name for the unique … Read more