DbContext和ObjectContext有什么区别? [英] What's the difference between DbContext and ObjectContext

查看:93
本文介绍了DbContext和ObjectContext有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN


表示Unit-工作和资源库模式,使您能够查询数据库并将更改组合在一起,然后将其作为一个单位写回商店。 DbContext 在概念上类似于 ObjectContext

我虽然 DbContext 仅处理与DB的连接和针对数据库的线程数。

I though DbContext only handle the connection to the DB and the number of threads working against the DB.

现在我明白它包含了跟踪机制?我以为这是在 ObjectContext 中。

Now I understand it contains the tracking mechanism? I thought this was in the ObjectContext.

那么什么是(简单的英语)他们之间的区别? / p>

So what is (in plain English) the difference between them?

推荐答案

DbContext是一个轻量级的ObjectContext类,它几乎位于ObjectContext之上(甚至有一种方法从DbContext得到ObjectContext)。使用更容易的IMO,并使CRUD操作变得更加简单。

DbContext is a lightweight version of the ObjectContext class, which is laid almost right on top of ObjectContext (there is even a way to get to the ObjectContext from just the DbContext). It's also a lot easier to use, IMO, and makes CRUD operations a sinch.

为了更好的信息,比 Julie Lerman 有关差异的更多信息,如带入EF 4.1。

For better information, who better to look to than Julie Lerman for more info on the differences, as was brought into EF 4.1.

这篇关于DbContext和ObjectContext有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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