数据注释的实体框架t4模板在哪里?

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

我已经停止了这个停止2天了,找不到一个完整的,准备使用的完全实现的生成DataAnnotations的t4模板。它们是否存在?

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模板生成POCO。实际的数据库表具有描述某些验证规则的元数据,例如,不为null,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.

所以我想要的是一个t4模板,拿我的桌子,并用 DataAnnotations生成一个POCO ,例如

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.

推荐答案

p> 这里是你想要的!

Here is what you want!

T4元数据和数据注释模板

T4 Metadata and Data Annotations Template

此T4模板处理从Entity Framework 4模型生成元数据类,并使用数据注释属性(如[Required]和[StringLength])来装饰属性。 [DataType] 属性也适用。它还将根据必填字段的属性名称生成 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:37:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581652.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:注释   实体   框架   模板   数据

发布评论

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

>www.elefans.com

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