After upgrading our project from using Entity Framework 5 to Entity Framework 6 (though NuGets update function) i get the following error on my generated Entities class:
I think your problem is, that your T4 templates, which generate the entitties and the context are still in EF version 5.
First you have to delete the current code generation items, which are in the code behind of the model, namely <Modelname>.Context.tt
and <Modelname>.tt
.Next add a new EF version 6 code generator with Right click in the model designer-> Add Code Generation Item ... -> EF 6.x DbContext Generator
.
Microsoft have a page on upgrading to EF6: https://docs.microsoft.com/en-us/ef/ef6/what-is-new/upgrading-to-ef6
Note: This may be same content @Kim Ki Won shows above but that link no longer works.
I know this is late to respond to the question but.
This work For me by following the below steps.
Copy the code form the existing abc.tt file. Delete the abc.tt file. Copy all the code again into ABC.tt file. After copy code just save the file and build the solution it will regenerate the complete .cs file as well
This is my experience on how to successfully upgrade Entity Framework v5 to v6 for:
Acronyms:
Checklist:
using System.Data.EntityClient;
, which is an EF5 reference.using System.Data.Entity.Core.EntityClient;
which is the correct for EF6.Still stuck? This checklist is a Community Wiki, feel free to edit this checklist to help other hapless souls who are still banging their heads against the brick wall that can be EF6 configuration.
Please explore other options before considering EF. It's 100x slower than other options, it's vastly over complicated for what it delivers, the entity GUI is full of bugs and has weird usability issues, and we are going to have to rip out all of our EF6 code and replace it with something that takes less than 5 minutes to make a query that takes 5 seconds in Dapper.