开发者

entity framework 4.1 objectContext vs dbContext [duplicate]

This question already has an answer here: Closed 10 years ago.

Possible 开发者_如何学JAVADuplicate:

ADO.NET DbContext Generator vs. ADO.NET Poco Entity Generator (ObjectContext)

Should I use ObjectContext or DbContext? What's the best way?


I am currently using DbContext in a Database first situation and it is working fine. DbContext is NOT only for Code First development.

DbContext acts like a wrapper around the ObjectContext. Julie Lerman has a nice explanation, how you can access the ObjectContext that is inside of DbContext here. So if you decide to use DbContext, you can still solve things with ObjectContext if you need to.

DbContext simplifies common tasks. One example is the Find() method.

Product p = db.Products.Find(id);


ObjectContext for version 4.0 when using a designer generated model and DbContext with a 4.1 Code First model.


It seems like when you use the designer generated model it automatically defaults to ObjectContext anyway

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜