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

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

问题描述

我已经编程了一段时间,之前已经使用LINQ-to-SQL和LINQ-To-Entities(虽然使用实体时它已经在一个Entity / Table 1-1关系上 - 即与L2SQL没有很大的不同) )



我一直在做很多关于控制反转,工作单位,POCO和存储库模式的阅读,并希望在我的新应用程序中使用这种方法。



我正在努力寻找一个清晰,简洁的EF4初学者指南,不会对EF1有所了解。



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



第一个/第一个模型?关于EF4的优点/缺点(即如果我先做代码,会发生什么,稍后更改代码,并需要重新生成我的数据库模型 - 数据是否被保存和转换或删除?)



假设我要进行代码优先(我想看看EF4如何将其转换为DB模式)如何实际开始?很多时候,我看到有实体图的文章说所以这是我的实体模型,现在我要去... - 不幸的是,我不清楚他们是否在设计师中创建了模型,将其保存到生成代码,然后停止任何进一步的自动代码生成 - 或者 - 他们编码(POCO)?课程和不知何故将他们导入deisgner视图?



我想我真正需要的是了解魔法来自哪里,如何自己添加我不是直接从数据库中生成一个EF模型。



我知道这个问题有点模糊,但我不知道我不会知道 - 所以任何输入/更正/澄清赞赏。



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

解决方案

这些文章可能是感兴趣的...该系列真正融入了POCO的优缺点方法。



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 /存档/ 2009/05/28 / POCO-内式实体框架部分-2-复杂类型延加载和 - 显式loading.aspx



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



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


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)

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.

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:

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?)

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?

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.

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

解决方案

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天全站免登陆