【发布时间】:2018-01-11 21:28:10
【问题描述】:
使用接受object 类型参数的HasAnnotation 方法向EF 模型添加纯字符串注释很容易,但尝试添加结构化注释会在构建迁移时出错:
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 注入有助于序列化结构化注释的方法?
为什么我需要它?只是试图在一个地方收集所有数据库元数据。而元通常是结构化信息。
【问题讨论】:
标签: .net entity-framework annotations entity-framework-core entity-framework-core-migrations