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
精彩评论