2

I have implemented the project of EntityFramework 6 into EntityFramework Core 3.1. In the EF6, we have HasColumnAnnotation() method used as sets an annotation in the model for the database column used to store the property.

Sample.cs

private void CreateCompositeUnique(DbModelBuilder modelBuilder, 
                                      string indexName)
{
    modelBuilder
    .Entity<Web>()
    .Property(x=>x.Url)
    .HasColumnAnnotation(IndexAnnotation.AnnotationName, 
    new IndexAnnotation(new IndexAttribute(indexName) { IsUnique = true }));
}

Refactor many HasColumnAnnotation and IndexAnnotation usages in my schema definition --> the link suggested HasIndex() method.But still confused whether its right or not?

and also I have to do migrate the HasColumnAnnotation() into HasIndex() using Roslyn API.

Kindly clarify on transformation and give solution for Roslyn part that how to do it same.

Karthic G
  • 1,162
  • 1
  • 14
  • 31

0 Answers0