Ben Finkel
Ben Finkel

Reputation: 4803

Updating my EF model to use 4.1 when I built it in 4.0

I built my EF Model in EF 4.0, and then installed the 4.1 upgrade that includes the new DBContext interface. How do I update my model so that it uses the 4.1 features going forward?

Thank You

Upvotes: 8

Views: 7296

Answers (2)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364259

You can use DbContext with your EDMX model. After installing EFv4.1 you should have new T4 template available: DbContext generator. This will take your EDMX and create context derived from DbContext and all POCO entities for you. Here you have walkthrough.

But if you want to switch to DbContext just because of DbContext.Entry.State you don't have to. EFv4 has a similar mechanism:

context.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified);

Here is the full description how to update an entity in EFv4.

Upvotes: 13

Joel C
Joel C

Reputation: 5567

What beneftis are you hoping to see by upgrading from EF4.0 to 4.1? You're obviously not going to benefit from using model-first development since you already have an existing model. You can already generate POCO objects from EF4.0. See Entity Framework upgrade from v4 to v4.1(RC)

Upvotes: 0

Related Questions