What is the difference between ObjectContext and DbContext?

Technology CommunityCategory: Entity FrameworkWhat is the difference between ObjectContext and DbContext?
VietMX Staff asked 3 years ago

Conceptually, both these are here for the same reason.

  • DBContext is wrapper around Object Context.
  • Prior to EF 4.1, EDM used to use Object Context as base class for Context classes.
  • There were some difficulties been observed in Object Context so now Db Context is introduced in EF 6.0 and this is used for all the development models –
  • Database First, Model First and Code First.
  • Object Context supports complied queries, but DB Context not.
  • Object Context supports self-tracking entities, but DB Context does not.
  • DB Context is thread safe, but Object Context not.