asp.net.netvisual-studioentity-frameworkasp.net-4.6

Upgrading .NET Framework 4.5 to 4.6.1 causes errors in Entity Framework classes


IDE :: VS.NET 2015

Version Upgrade :: 4.5 To 4.6.1

My asp.net solution contains more than 30 projects inside. I have upgraded the targeted framework to 4.6.1 and now i am getting these tons of error in EF classes. The existing EF version is 6.0.

Please suggest how to fix these errors cropped up from the EF classes. Should i upgrade the EF version also from the Nuget console also.

enter image description here


Solution

  • If you have any models created with the EF Designer, you will need to update the code generation templates to generate EF6 compatible code.

    1. Delete existing code-generation templates. These files will typically be named .tt and .Context.tt and be nested under your edmx file in Solution Explorer. You can select the templates in Solution Explorer and press the Del key to delete them. Note: In Web Site projects the templates will not be nested under your edmx file, but listed alongside it in Solution Explorer. Note: In VB.NET projects you will need to enable 'Show All Files' to be able to see the nested template files.

    2. Add the appropriate EF 6.x code generation template. Open your model in the EF Designer, right-click on the design surface and select Add Code Generation Item... If you are using the DbContext API (recommended) then EF 6.x DbContext Generator will be available under the Data tab. Note: If you are using Visual Studio 2012, you will need to install the EF 6 Tools to have this template. See Get Entity Framework for details. If you are using the ObjectContext API then you will need to select the Online tab and search for EF 6.x EntityObject Generator.

    3. If you applied any customizations to the code generation templates you will need to re-apply them to the updated templates.