📅  最后修改于: 2022-03-11 14:55:01.656000             🧑  作者: Mango
// before
modelBuilder.Entity()
.Property(e => e.Name)
.HasColumnAnnotation(
IndexAnnotation.AnnotationName,
new IndexAnnotation(new IndexAttribute { IsUnique = true }));
// after
modelBuilder.Entity()
.HasIndex(p => p.Name)
.IsUnique();
// multi column index
modelBuilder.Entity()
.HasIndex(p => new { p.Name, p.Firstname })
.IsUnique();