我正在使用实体框架并通过 T4 生成我的 POCO 类 - 这些类从无到有继承并且非常简单(通过 vs 2010 中的模板创建)
我尝试使用元数据类型属性,这样我就可以创建一个伙伴类,但是当我这样做时,我不再能够看到我的属性......如果我删除了该属性!属性出现了。
无论如何,深入搜索我发现了微软的这个声明
The associated class must be used with EDM or LINQ-to-SQL models because CLR
types cannot mark existing properties with new attributes. If you are working with CLR
objects directly, sometimes referred to as Plain Old CLR Object (POCO) types, you can
apply the attributes directly to the model
所以它似乎不起作用?无论如何,我很难在模型本身上插入我的数据注释,因为它是通过 T4 创建的,因此如果我对其进行编辑然后重新运行该工具,它将删除我的所有更改。
有没有人设法让它工作?
我真的很挣扎。