views:

283

answers:

1

I'm following a tutorial by Scott Gu that refers to a class named DbContext. I can't find it on any namespace on framework 4 and it seems to me it was renamed from CT4 DbContext to .net4 System.Data.Linq.DataContext. Is my assumption correct?

+3  A: 

DbContext is a new class that was added in the recent separate down by EF team. It is currently not part of the core EF 4.0. However DbContext moving forward would be the preferered way to interact with EF. So how is it different from Objectcontext? Well semantically there are exactly same but they reduced lot of extra noise that ObjectContext had. Like exposing a set required more work for instance

public ObjectSet<Customer> Customers
{
 get{return db.CreateObjectSet<Customer>();
}

in dbcontext u can do public DbSet Customers{get;set;}

Basically on the ObjectContext, when you do dot(.), everything is just right there which makes the list pretty huge. What the EF team actually wanted to expose on DbContext are entities which are only speicific to your domain and rest of ability of the framework is tucked in under different properties. It just makes the programming experience easier. This means if you are using ObjectContext write now, with little bit of code, you can easily move to DbContext.

zeeshanhirani
Any idea on when it will be merged into the main framework branch?
Padu Merloti