Question

Possible Duplicate:
ObjectContext vs DbContext

The author of this answer wrote that https://stackoverflow.com/a/12494339/1662812 "Both T4 and DbContext API are currently recommended approach for using EF"

I still wonder what exactly is the difference between DbContext API and ObjectContext API when used with Entity Data Model and I am also looking for any reference about DbContext API being recommended approach for using EF.

Was it helpful?

Solution

"DbContext is much simpler to use than ObjectContext and will serve the most common development needs. if you need more, you can drop down into the ObjectContext.

Remember that DbContext sits on top of the ObjectContext. The ObjectContext is always there in the background doing it’s work. So if you need to do something very granular, DbContext provides a hook to its underlying ObjectContext." from http://thedatafarm.com/blog/data-access/code-first-and-dbcontext-are-now-ldquo-the-entity-framework-rdquo/. She is in EF team, also has good video about that on Pluralsight.

From my point of view, DbContext is easier to use, and covers almost everything you need. I always make an extension method for exposing object context (methods from it) if I need them somewhere.

OTHER TIPS

I think Julie Lermann is the source for that

http://msdn.microsoft.com/en-us/magazine/hh781018.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top