Entity-framework – Upgrade EF 4 EDMX to EF 6

entity-frameworkentity-framework-4entity-framework-6

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.

Best Answer

  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
Related Topic