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.

 

Advertisements
Posted in Tips and others, Visual Studio
2 comments on “How to migrate EntityFramework 5 to EntityFramework 6 with Visual Studio 2015
  1. […] this framework. Why? First for performance reasons and secondly to avoid maintenance problems (see my previous article about the migration of EF5 to […]

  2. Desi Chinese says:

    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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: