10

We have recently upgraded our Visual Studio from 2010 to 2013. With it came EF 6.0, which is incompatible with the code generated from EF 4.

I need to update a table in the model with the latest version from the DB schema. When doing that, both "Update" and "Add" after deletion of the table definition do the following:

  • Remove all custom code already written for all types in the model, even if they are in separate files than the model;
  • Generate the new EF 6.0 bindings;
  • (optionally) Generate the new repository. Now, that's obviously not the same behavior as in EF 4, which only regenerated the repository and did not touch the custom code.

We are not using NuGet, but referencing the EF library inside the project.

I guess VS 2013 uses a different version of the code generator than VS 2010. How can we revert to the old behavior?

UPDATE: I have tried using NuGet to download EF 4.3.1 and repeat the update model steps (also delete and then recreate), but I am still seeing the old behavior. I think there is a problem with the VS 2013 EF Code Generator.

1
  • 3
    I've similiar issue, this is so annoying.
    – Cleiton
    Feb 7, 2014 at 19:51

1 Answer 1

16

For me, the following solution worked.

Double-click on your edmx file and open its properties window. Change Code Generation Strategy from T4 to Legacy Object Context. Build your solution. It may cause thousands of errors because you have redeclared functions and properties, so remove all files that weren't there before.

edmx properties window

1
  • 1
    I would prefer a permanent solution. I have this value resetting every time I update the model from the database. Apr 24, 2014 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.