ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator(ObjectContext) [英] ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator (ObjectContext)

查看:109
本文介绍了ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator(ObjectContext)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我即将开始实施一个以DDD方式架构的项目的数据访问基础设施(这是我第一次尝试DDD,所以要温柔; - ))。

I am about to start implementing the data access infrastructure of a project that was architected with an approach to DDD (it's my first attempt on DDD, so be gentle ;-) ).

我将使用实体框架。直到现在,我正在研究Julie Lerman在她伟大的书上教授的方法,编程实体框架,其中使用了 ADO.NET POCO实体生成器 ,对T4模板进行了一些更改以及一些更多的自定义代码。

今天我开始阅读文章EF4.1和 ADO.NET DbContext生成器 ,使用 数据库优先 方法,我试图决定哪一个我应该去。

I will be using Entity Framework. Until now, I was looking into the method teached by Julie Lerman on her great book, Programming Entity Framework, where ADO.NET POCO Entity Generator is used, with some changes to the T4 templates and some more custom code.
Today I started reading articles on EF4.1 and the ADO.NET DbContext Generator, using Database First approach, and I'm trying to decide with which one should I go.

DbContext和EF4.1的DDD方法似乎比POCO Entities更好,更干净,但我是因为EF4.1仍然在RC,所以恐怕可能会导致一些问题。

DbContext and EF4.1's approach on DDD seems to be a nice, cleaner way than POCO Entities, but I'm afraid that it could lead to some issues in the near future, since EF4.1 is still in RC.

ADO.NET团队博客,我知道EF4。 1 包括:

From ADO.NET team blog, I know that EF4.1 does not include:


  • 枚举支持

  • 空间数据类型支持

  • 在Code First中存储过程支持

  • 代码优先的迁移支持

  • 代码优先的可定制约定

  • Enum support
  • Spatial data type support
  • Stored Procedure support in Code First
  • Migration support in Code First
  • Customizable conventions in Code First

从我的理解,因为我将使用 数据库优先 ,没有包含较少数量的功能。

From my understanding, since I will be using Database First there is a smaller number of features that were not included.

总而言之,我的问题是:

我可以用EF4.1 DbContext Generator替换POCO实体生成器?

In conclusion, my question is:
Can I replace POCO Entities Generator with EF4.1 DbContext Generator?

推荐答案

从POCO实体的 clean 创建的角度来看,两个生成器之间没有区别。两个生成器都生成相同的实体,但是,ADO.NET POCO Entity Generator基于 ObjectContext 的API,而ADO.NET DbContext 生成器基于 DbContext 的API。

From a point of view of clean creation of POCO entities, there is no difference between the two generators. Both generators produce the same entities, however, ADO.NET POCO Entity Generator is based on ObjectContext's API, whereas ADO.NET DbContext Generator is based on DbContext's API.

DbContext的API有一些非常好的新功能(本地,导航属性查询等)和API以某种方式进行了简化,但同时在DbContext API中缺少ObjectContext API中使用的某些功能(或者至少还没有被探索到)。

DbContext's API has a few very nice new features (Local, Query on navigation property, etc.) and API is somehow simplified but at the same time it looks like some features used in ObjectContext API are missing in DbContext API (or at least it has not been explored enough yet).

EF 4.1 RC是go-live发行版。这意味着您可以使用它构建一个真正的应用程序,因为API在RTW中不会改变(只有错误将被修复)。另外RTW应该在下个月,所以我认为你的应用程序将不会在最终版本发货之前准备好。

EF 4.1 RC is go-live release. It means that you can build a real application with it because API will not change in RTW (only bugs will be fixed). Also RTW should be in the next month so I think you will not be ready with your application before the final version is shipped.

ObjectContext API或 DbContext API? ObjectContext API更好地被文档和博客文章覆盖。你可以找到很多关于它的例子。它的局限也是众所周知的。 DbContext API是新版本。这是一个非常有希望的版本,主要是因为采用了代码优先的方法。博客文章数量仍然很少,没有书籍和API没有足够证明。那么这取决于你是否准备好与新的API进行战斗?如果没有,那么 ObjectContext API仍然是一个不错的选择,因为您不需要首先使用代码。

ObjectContext API or DbContext API? ObjectContext API is much better covered by documentation and blog posts. You can find plenty of examples about it. Also its limitations are already well known. DbContext API is new release. A very promising release, mostly because of the code-first approach. There is still a very limited number of blog posts, no book and the API is not proven enough. So it depends if you are ready to fight with new API? If not, then ObjectContext API is still a good choice because you don't need the code-first approach.

这篇关于ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator(ObjectContext)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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