It is easy to add plain string annotations to the EF model with HasAnnotation
method that accept object
type of argument, but trying to add structured annotations you will get errors on build migration:
modelBuilder.Entity<Group>().HasAnnotation($"{GetType().FullName}.Constraint3", new ValueTuple<string,string>( "aaa", "bbb" ));
The current CSharpHelper cannot scaffold literals of type 'System.ValueTuple`2[System.String,System.String]'. Configure your services to use one that can.
modelBuilder.Entity<Group>().HasAnnotation($"{GetType().FullName}.Constraint2", new[] { "aaa", "bbb" });
The current CSharpHelper cannot scaffold literals of type 'System.String[]'. Configure your services to use one that can.
Do we have a way to inject a method to the target builder
that would help to serialize structured annotations?
Why I would need it? Just trying to collect all database meta in one place. And meta is usually structured info.