3

I am currently finalizing the architecture of my new application that will be using Entity Framework as its ORM. However, I am a little bit confused with respect to whether I should go with the default option (DbSet and DbContext), or use a "tricky" option (ObjectSet and ObjectContext)? Do the latter classes offer advantages over the default classes?

DavidRR
  • 18,291
  • 25
  • 109
  • 191
Nirman
  • 6,715
  • 19
  • 72
  • 139
  • Possible duplicate of [Is it always better to use 'DbContext' instead of 'ObjectContext'?](https://stackoverflow.com/questions/10475306/is-it-always-better-to-use-dbcontext-instead-of-objectcontext) – DavidRR Aug 18 '17 at 18:13

2 Answers2

4

There are several posts on this topic which go into detail about your question, and I'm sure you will find helpful:

On DbContext, is it strictly better than ObjectContext?

entity framework 4.1 objectContext vs dbContext

ObjectContext vs DbContext

difference between DBContext and Object context in Entity Framework

Community
  • 1
  • 1
atconway
  • 20,624
  • 30
  • 159
  • 229
2

Just summarization. DbContext is a wrapper around the ObjectContext. You can also access ObjectContext by DbContext if you need. ObjectContext came with EF4 and DbContext with EF4.1. Basically both contexts are almost same. DbContext simplifies many things. Moreover DbContext doesn't contains hundreds of properties like ObjectContext - it is more clear and compact.

Milan Matějka
  • 2,654
  • 1
  • 21
  • 23