ADO.NET DbContext 生成器与 ADO.NET Poco 实体生成器 (ObjectContext) [英] ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator (ObjectContext)

查看:53
本文介绍了ADO.NET DbContext 生成器与 ADO.NET Poco 实体生成器 (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 Generator 的文章,使用数据库优先方法,我正在努力决定我应该去哪个.

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 实体更好、更干净,但我担心它可能会在不久的将来导致一些问题,因为 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 中的存储过程支持
  • Code First 中的迁移支持
  • 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 Entities Generator 吗?

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

推荐答案

clean 创建 POCO 实体的角度来看,两个生成器之间没有区别.两个生成器生成相同的实体,但是,ADO.NET POCO 实体生成器基于 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 在某种程度上得到了简化,但与此同时,ObjectContext API 中使用的某些功能似乎在 DbContext 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 是上线版本.这意味着您可以用它构建一个真正的应用程序,因为 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 生成器与 ADO.NET Poco 实体生成器 (ObjectContext)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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