Upgrade EF 4 EDMX to EF 6

SolarX picture SolarX · Oct 21, 2013 · Viewed 25.4k times · Source

My application is using a database first EDMX in EF 4. I would like to upgrade everything to EF 6. After getting EF 6 with NuGet I had to make a lot of changes to my classes that are using my EF model, because namespaces have been changed in EF 6. Then I realized, that the code generated by my EDMX does also use the wrong namespaces etc. I'm not using a custom T4 so far.

How would I upgrade my existing EDMX to EF 6.

Thank you.

Answer

Rand Random picture Rand Random · Oct 21, 2013
  1. You delete your old .tt files
  2. You open your edmx file in designer mode (so you can see your model)
  3. Right click on a free space
  4. Select Add Code Generation Item
  5. In the dialog select "EF 6.x DbContext Code Generation Item" (something like this)
  6. Save your edmx and all classes will be generated for you, with the new namespaces and so on