2

I'm trying to read buddy class metadata information for usage outside of the normal asp.net mvc 2 validation process. I thought it would be as simple as saying:

DataAnnotationsModelMetadataProvider metadataProvider = new DataAnnotationsModelMetadataProvider();

var metaData = metadataProvider.GetMetadataForType(() => new T(), typeof (T));

That works, but is returning me the entire types metadata information and not just what is in the buddy information. According to the MVC2 source ( It uses the buddy class support from DataAnnotations, ) it should support getting the buddy data information but I don't see the part in the code where it reflects into the Metadatatype() attribute.

Generally confused here. Did I miss an overload or something?

4

1 回答 1

0

我有同样的问题。我已经查看了 30 篇或 40 篇关于为什么这个实体框架“数据库优先”部分类不起作用的教程。然后我发现这篇文章——MVC 4 EF5 Database First set Default Values in Partial Class——给出了以下建议:

[元数据类型(typeof(CompanyMD))]

属于由 EF 生成的部分类,即使当您更改模型时它将被删除。因此,您的 EF 生成的文件应如下所示:

于 2013-01-22T07:15:41.947 回答