HasAnnotation
使用接受参数类型的方法向 EF 模型添加纯字符串注释很容易object
,但是尝试添加结构化注释会在构建迁移时出错:
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.
我们是否有办法target builder
将有助于序列化结构化注释的方法注入?
为什么我会需要它?只是试图在一个地方收集所有数据库元数据。而元通常是结构化信息。