实体框架POCO/T4混乱 [英] Entity framework POCOs/T4 confusion
问题描述
大家好,
我将要使用Entity Framework 4/WCF/.NET4上的其他常见嫌疑人来开始一个大型项目,但是我对各种T4模板和POCO感到困惑,并且正在寻找我应该使用的帮助.
我希望编写各种类,例如Order(),这些类的属性将映射到SQL列,但是我还需要对这些属性(可能是Ent Lib Validation AB)以及业务逻辑进行验证.
我的问题是我不确定应该使用哪个模板以及如何正确使用它.我必须为我创建的每个新数据库表列创建属性吗?我可以让模型仍然管理我的关系吗?
感谢您在这里的任何建议.
Hi all,
I''m about to start a large project using Entity Framework 4/WCF/the other usual suspects on .NET4 but I am confused about the various T4 templates and POCOs and was looking for some help on which I should be using.
I wish to write various classes such as Order() of which properties will map to SQL Columns but I also need to put validation on these properties (probably Ent Lib Validation AB) and also business logic.
My question I''m unsure which template I should be using and how I use it exactly. Do I have to create properties for each new db table column I create? Can I have the model still manage my relationships?
Thanks for any advice here.
推荐答案
我建议使用VS2010 Extension Manager中提供的"ADO.NET C#POCO实体生成器".
我曾在一个具有与您描述的特性相似的项目中使用过它,并获得了出色的结果.
生成的实体都是部分实体,因此您可以使用元数据和附加行为进行扩展.
I recomend using the "ADO.NET C# POCO Entity Generator" available at VS2010 Extention Manager.
I used that in a project with similar caracteristics as you described with excelent results.
The entities generated are all partials so you can extend then with metadata and aditional behaviors.
这篇关于实体框架POCO/T4混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!