Hello,
I'm migrating my code from .net core 3.1 to .net 5.0
All works well except for one thing.
On my columns in my Entities I have created a custom Annotation
like this
[CustomAnnotiation("Some key", "Interval in ms")]
public int Interval { get; set; }
when using add-migation,
this annotation was added to the dbcontext and also migration script like this
migrationBuilder.AlterColumn<int>(
name: "Interval",
table: "Tables",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("CustomAnnotiation:Some key", "Interval in ms");
and when using update-database some custom sql was used.
when updating to .net 5 the annotion to the migration script fails And I can't pinpoint how to fix this.
previously I had an override on
Microsoft.EntityFrameworkCore.SqlServer.Migrations.Internal.SqlServerMigrationsAnnotationProvider.For(IProperty property)
but this method is gone in .net 5.
my override was like this
public override IEnumerable<IAnnotation> For(IProperty property)
{
var result = base.For(property);
foreach(var annotation in result)
{
yield return annotation;
}
var annotations = property.GetAnnotations();
foreach(var annotation in annotations.Where(a => a.Name.StartsWith("CustomAnnotiation"))
{
yield return new Annotation(
annotation.Name,
annotation.Value);
}
}
but checking the new EF code I saw IColumn makes his introcuduction,
and seems to be used for generating the Annotations.
Still is seems to be that the annotations are added to the IProperty part, but read from IColumn
where setting _annotiation always is empty.
and I'm missing where to fix this.
can someone help me to point in the correct direction?