Индекс Аннотации к EF Core - PullRequest
       66

Индекс Аннотации к EF Core

0 голосов
/ 05 декабря 2018

У меня есть этот код в EF 6.2

public class ClientNotificationMap : EntityTypeConfiguration<ClientNotification>
{
    public ClientNotificationMap()
    {
        HasKey(x => x.RelationalId);

        Property(x => x.SubscriptionId)
            .IsRequired()
            .HasMaxLength(400)
            .HasColumnAnnotation(IndexAnnotation.AnnotationName, new  IndexAnnotation(new IndexAttribute()));
     }
}

, который я хочу перенести в Core 2.2

public class ClientNotificationMap : IEntityTypeConfiguration<ClientNotification>
{
    public ClientNotificationMap()
    {

    }

    public void Configure(EntityTypeBuilder<ClientNotification> builder)
    {
        builder.HasKey(x => x.RelationalId);

        builder.Property(x => x.SubscriptionId)
            .IsRequired()
            .HasMaxLength(400)
            .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute()));
    }
}

Кто-нибудь знает, как изменить

                .HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(new IndexAttribute()));

В Core это не поддерживается.Также я не нахожу ничего относительно Интернета.

1 Ответ

0 голосов
/ 05 декабря 2018

В конце я написал код

        builder.HasIndex(x => x.SubscriptionId)
            .IsUnique();

        builder.Property(x => x.SubscriptionId)
            .IsRequired()
            .HasMaxLength(400);

, он компилируется как минимум

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...