'ObjectContext' vs 'DbContext' in Entity Framework

25,008

DbContext is just a wrapper around ObjectContext.

DbContext is just a set of APIs that are easier to use than the APIs exposed by ObjectContext.

Anyway, here you'll find a very simple Visual Studio template that uses the Repository Pattern and the Entity Framework.

Share:
25,008
afr0
Author by

afr0

Updated on August 19, 2020

Comments

  • afr0
    afr0 over 3 years

    I'm using the DbContext class within code that I am creating that is based on the Generic Repositories and Unit of Work design patterns. (I am following the guidance here.) While working on this project I have encountered the ObjectContext class.

    I've read quite a number of posts that discuss ObjectContext vs. DbContext. While some of what I've read makes sense, I still don't have a complete understanding of the differences and this leaves me wondering about my current implementation. Should I be using DbContext, ObjectContext or both? Is using one of these now considered an anti-pattern?

  • Shaiju T
    Shaiju T over 8 years
    check this article for more
  • Jan Muncinsky
    Jan Muncinsky over 6 years
    this one throws StackOwerflowException. See msdn.microsoft.com/library/ms182153.aspx