哪里可以找到数据注释实体框架T4模板?

编程入门 行业动态 更新时间:2024-10-27 06:28:36
本文介绍了哪里可以找到数据注释实体框架T4模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直在谷歌上搜索,现在2天本不停止,不能找到一个完整的,随时使用,全面实施T4模板生成DataAnnotations。难道他们甚至还存在?

I have been googling this non stop for 2 days now and can't find a single complete, ready to use, fully implemented t4 template that generates DataAnnotations. Do they even exist?

我生成标准的T4模板波苏斯。实际的数据库表有介绍了一些验证规则,如不为空,为nvarchar(25)等元数据。

I generate POCOs with the standard t4 templates. The actual database table has metadata that describes some of the validation rules, eg not null, nvarchar(25), etc.

因此​​,所有我想要的是可以把我的表,并生成一个POCO T4模板的与的DataAnnotations,如:

So all I want is a t4 template that can take my table and generate a POCO with DataAnnotations, eg

public class Person { [Required] [StringLength(255)] public FirstName {get;set} }

这是一个基本的和根本要求,当然我不能成为第一人,在整个世界上有这样的要求吗?我并不想在这里重新发明轮子。然而,我没有寻找高和低天后发现了它。

It is a basic and fundamental requirement, surely I can not be the first person in the entire world to have this requirement? I don't want to re-invent the wheel here. Yet I haven't found it after searching high and low for days.

这必须是可能的(希望必须是可用的地方只下载) - 这将是刑事责任错得的手动的这些注释类型时,对它们的元数据已经存在于数据库中。

This must be possible (and hopefully must be available somewhere to just download) - it would be criminally wrong to have to manually type in these annotations when the metadata for them already exists in the database.

推荐答案

这里是你想要的!

T4元数据和数据注释模板

T4 Metadata and Data Annotations Template

本T4模板处理从实体生成的元数据类  Framework 4的模型和装饰数据注释属性  属性,如[必需]和[StringLength]。在[数据类型]  属性也被施加在适当的时候。它也将产生  为必填项基于属性名称的ErrorMessage值。

This T4 template handles generating metadata classes from an Entity Framework 4 model and decorates properties with data annotation attributes such as [Required] and [StringLength]. The [DataType] attribute is also applied when appropriate. It'll also generate ErrorMessage values based upon property names for required fields.

更多推荐

哪里可以找到数据注释实体框架T4模板?

本文发布于:2023-11-12 13:38:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可以找到   注释   实体   框架   模板

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!