Question

I have this code in 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()));
     }
}

which I want to migrate to 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()));
    }
}

Does anyone know how to change the

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

In Core it doesn't seem to be supported. Also I don't find anything relative to the web.

1
0
12/5/2018 11:09:30 AM

Popular Answer

In the end I wrote the code

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

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

it compiles at least

0
12/5/2018 11:24:48 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow