2018-04-27

How to migrate EntityFramework 5 to EntityFramework 6 with Visual Studio 2015

If you have developed your application with EntityFramework 4 or 5, using the graphical model designer EDMX… May be you received a compilation error after some updates of this EDMX. Why ? Because the model is different with EF6. See this Microsoft Magazine article for more information: https://msdn.microsoft.com/en-us/magazine/dn532202.aspx.

The solution is described in the new file generated by the new EF Visual Studio Wizard: T4 code generation is enabled for your model. To enable legacy code generation, change the value of the ‘Code Generation Strategy‘ designer property to ‘Legacy ObjectContext’. This property is available in the Properties Window when the model is open in the designer.

So, you need to update your EDMX, to delete new generated files (below .tt files), change the property Code Generation Strategy to Legacy ObjectContext and save your EDMX to re-generate all classes.

Watch this short video to a full example.

 

2 thoughts on “How to migrate EntityFramework 5 to EntityFramework 6 with Visual Studio 2015

  1. Thanks for every other wonderful post. Where else may anyone get that type of info in such an ideal manner of writing?
    I have a presentation subsequent week, and I’m at the search for such info.

Leave a Reply

Your email address will not be published. Required fields are marked *