How can Entity Framework Code First Create Index in Descendent order?
问题 In fluent API, we can specify an Index on a field: var indexAttr = new IndexAttribute("IX_EmployeeNumber") { IsClustered = true }; Property(c => c.EmployeeNumber) .HasColumnAnnotation("Index", new IndexAnnotation(indexAttr )) .HasMaxLength(8) .IsRequired(); After Add-Migration , we will get this CreateIndex statement: CreateIndex("dbo.Employees", "EmployeeNumber", clustered: true, name: "IX_EmployeeNumber"); After a Update-Database , we have a sql like this: CREATE CLUSTERED INDEX [IX