为实体框架自动生成元数据类

发布于 2024-08-20 18:42:34 字数 392 浏览 7 评论 0 原文

我正在考虑使用 xVal 来验证 MVC 应用程序中的实体框架类。这涉及编写元数据类,如 Graham O'Neale 详细解释的那样 (http://goneale.com/2009/03/04/using-metadatatype-attribute-with-aspnet-mvc-xval-validation-framework)。

我想知道是否有一种方法可以使用 SQL 数据库中的元数据自动生成此类元数据类(例如:非空字段将具有 [Required] 类属性。

I am considering using xVal for validation of Entity Framework classes in a MVC application. This involves writing metadata classes as explained in details by Graham O'Neale (http://goneale.com/2009/03/04/using-metadatatype-attribute-with-aspnet-mvc-xval-validation-framework).

I am wondering if there's a way to auto generate such metadata classes using the metadata from the SQL database (for example: not null fields will have [Required] class attribute.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫南 2024-08-27 18:42:34

你可以使用Code Smith工具www.codesmithtools.com(如果我没记错的话有一个免费版本)

You could use Code Smith tool www.codesmithtools.com (there is a free version if I remember correctly)

若水般的淡然安静女子 2024-08-27 18:42:34

我编写了一个应用程序,它将读取现有数据库,然后为每个表(不包括 aspnet_* 和 VersionInfo)生成数据注释类。

http://pfsolutions-mi.com/Product/MetaDataClassGenerator

I wrote an application that will read an existing database and then generate a Data Annotation Class for every table (excluding aspnet_* and VersionInfo).

http://pfsolutions-mi.com/Product/MetaDataClassGenerator

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文