I'm trying to upgrade a project from EF 4.3.1 to EF 6.0
The template uses ObjectContext
and now, whenever I change the template, it's overwriting the generated code in the *.Designer.cs file with the old EF 4.3.1 namespaces, so the build breaks.
Is there any way I can stop this from happening? I can't see a *.tt file to hack around with. Regenerating the EDMX isn't really an option as there have been significant customisations to the conceptual model (I'd be at it for days!).
I've tried creating a new EDMX as a test and that exhibits the same problem. As soon as I change code generation to 'Default' for ObjectContext
usage the EDMXName.Designer.cs file is written using the old namespaces.
using System;
using System.ComponentModel;
using System.Data.EntityClient;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml.Serialization;
This is driving me to distraction - I think I'm going to have to hack it down to EF 5.0
An . edmx file is an XML file that defines an Entity Data Model (EDM), describes the target database schema, and defines the mapping between the EDM and the database. An . edmx file also contains information that is used by the ADO.NET Entity Data Model Designer (Entity Designer) to render a model graphically.
Versions 6.0, 6.1, 6.2, and 6.3 are no longer supported. Although Entity Framework 6. x is still supported, it is no longer being developed and will only receive fixes for security issues.
Open you model in the EF Designer, right-click on a blank section of the design surface and select Properties. In the Properties window change the Code Generation Strategy from None to Default.
I have solved the problem. It is because you've upgraded to EF 6.X from EF 5.X your edmx is still on the old legacy generation strategy.
What you need:
Update all projects using Nuget to EF 6 release
For C# download http://visualstudiogallery.msdn.microsoft.com/66612113-549c-4a9e-a14a-f629ceb3f89a
For VB.net download http://visualstudiogallery.msdn.microsoft.com/ff479d55-2c85-43c5-a4d6-21cd659435ea
After installing 1 of these extensions you want to backup your edmx and designer files (or use source control). Restart Visual Studio.
After restarting Visual Studio you want to go into your project and:
T4
This gives you your ObjectContext
derived context as well as everything matching the newer EF 6.0 namespaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With