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.
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
It should be something like this:
builder.HasIndex(x => new { x.SubscriptionId})
.HasDatabaseName("IX_SubscriptionId")
.HasFilter(null)
.IsUnique(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With