EF can you make a Mutli-column Index using shadow properties?

后端 未结 1 1024
离开以前
离开以前 2021-01-18 05:36

I\'m trying to create a multi-column unique index using a shadow property. I know I can solve this problem with just adding a property, but I would like to see if this is po

1条回答
  •  走了就别回头了
    2021-01-18 06:05

    It's possible. You can simply use the HasIndex overload with params string[] propertyNames.

    First make sure the shadow property is defined:

    modelBuilder.Entity()
        .Property("AlbumId");
    

    and then define the index:

    modelBuilder.Entity()
        .HasIndex("TrackNumber", "AlbumId")
        .IsUnique();
    

    0 讨论(0)
提交回复
热议问题