实体框架 4/POCO - 从哪里开始? [英] Entity Framework 4 / POCO - Where to start?

查看:44
本文介绍了实体框架 4/POCO - 从哪里开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编程了一段时间,之前使用过 LINQ-To-SQL 和 LINQ-To-Entities(尽管在使用实体时,它一直处于实体/表 1-1 关系上 - 即与 L2SQL 没有太大区别)

I've been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although when using entities it has been on a Entity/Table 1-1 relationship - ie not much different than L2SQL)

我阅读了大量有关控制反转、工作单元、POCO 和存储库模式的阅读材料,并希望在我的新应用程序中使用这种方法.

I've been doing a lot of reading about Inversion of Control, Unit of Work, POCO and repository patterns and would like to use this methodology in my new applications.

我正在努力寻找一个清晰、简洁的 EF4 初学者指南,该指南不假定您具备 EF1 知识.

Where I'm struggling is finding a clear, concise beginners guide for EF4 which doesn't assume knowledge of EF1.

我需要回答的具体问题是:

The specific questions I need answered are:

代码优先/模型优先?EF4 的优缺点(即,如果我先编写代码,稍后更改代码并需要重新生成我的数据库模型,会发生什么情况 - 数据是否得到保留、转换或删除?)

Code first / model first? Pros/cons in regards to EF4 (ie what happens if I do code first, change the code at a later date and need to regenerate my DB model - Does the data get preserved and transformed or dropped?)

假设我要以代码为先(我想看看 EF4 如何将其转换为 DB 模式)我该如何真正开始?我经常看到带有实体图的文章说这是我的实体模型,现在我要......" - 不幸的是,我不清楚它们是否是在设计器中创建的模型,并将其保存到生成代码然后停止任何进一步的自动代码生成 - 或者 - 他们已经编码(POCO)?类和以某种方式将它们导入到设计器视图中?

Assuming I'm going code-first (I'd like to see how EF4 converts that to a DB schema) how do I actually get started? Quite often I've seen articles with entity diagrams stating "So this is my entity model, now I'm going to ..." - Unfortunately, I'm unclear if they're created the model in the designer, saved it to generate code then stopped any further auto-code generation -or- They've coded (POCO)? classes and the somehow imported them into the deisgner view?

我想我真正需要的是了解魔法"的来源以及如果我不只是直接从数据库生成 EF 模型,如何自己添加它.

I suppose what I really need is an understanding of where the "magic" comes from and how to add it myself if I'm not just generating an EF model directly from a DB.

我知道这个问题有点含糊,但我不知道我不知道什么 - 所以任何输入/更正/澄清表示赞赏.

I'm aware the question is a little vague but I don't know what I don't know - So any input / correction / clarification appreciated.

不用说,我不希望有人坐在这里教我 EF - 我只是想要一些好的教程/论坛/博客/等.对于完整的实体新手

Needless to say, I don't expect anyone to sit here and teach me EF - I'd just like some good tutorials/forums/blogs/etc. for complete entity newbies

推荐答案

这些文章可能会引起您的兴趣...该系列文章真正探讨了 POCO 方法的优缺点.

These articles might be of interest...the series really gets into the advantages and disadvantages of a POCO approach.

http://blogs.msdn.com/b/adonet/archive/2009/05/21/poco-in-the-entity-framework-part-1-the-experience.aspx

http://blogs.msdn.com/b/adonet/archive/2009/05/28/poco-in-the-entity-framework-part-2-complex-types-deferred-loading-and-explicit-loading.aspx

http://blogs.msdn.com/b/adonet/archive/2009/06/10/poco-in-the-entity-framework-part-3-change-tracking-with-poco.aspx

在这些文章中,作者提到了未来的文章,这些文章描述了实现存储库和工作单元模式的最佳实践,但我找不到它们.这些文章写得很好,我想从这位作者那里读到更多.

In these articles the author mentions future articles that describe best practices in implementing Repository and Unit of Work patterns, but I can't find them. These articles are well written and I'd like to read more from this author.

这篇关于实体框架 4/POCO - 从哪里开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆