4

We're using the Entity Framework and we created our EDMX when our project was set to build .NET 4.5. Now we want to switch to .NET 4.0 but when we do, we get compilation errors for the EDMX file.

It states the following error:

Error 10027: The XML namespace for the conceptual model's schema element is not supported on this project's target framework version.

Is there any solution other than recreating the EDMX file?

firebird
  • 3,461
  • 6
  • 34
  • 45
  • I don't think so. Surely its easy enough to just re-create the EDMX? – Greg Sep 10 '13 at 16:10
  • 1
    For what its worth I switched the target framework back to 4.5, recompiled the solution, got a bunch of errors, switched it back to 4.0 and got the message: "Successfully rebuilt the edmx for the new target framework" and was able to recompile without any namespace errors *shrug* – Bauhaus Apr 30 '14 at 17:26
  • @Bauhaus Can you please make your comment an answer. It solved my problem and I think it may be useful to others as well. – Tjaart Mar 13 '15 at 09:32

3 Answers3

4

Assuming you don't use features that shipped with .NET Framework 4.5 (enums, spatial types, stored procs with multiple result sets) you can do the following (be sure to back the file up just in case):

  • Create a new console app targeting .NET Framework 4.5
  • Add the edmx file to the project
  • Retarget the project to target .NET Framework 4 (go to project properties, change target framework version)

This should result in downgrading your edmx to v2.

Alternatively you could manually change xml namespaces and versions to v2. You can find what namespace to use for each version of the artifact here:

Edit Note that with EF6/EF6.x you can use Edmx v3 on .NET Framework 4 and therefore get all the goodnes (like enums) that was before only available on .NET Framework 4.5

Pawel
  • 31,342
  • 4
  • 73
  • 104
  • Hi Pawel. How is it possible to use edmx v3 on .NET4 and EF6... Would you not get the eeror stated in this question? – MajorInc Sep 17 '14 at 21:47
  • Using edmx v3 on .NET Framework 4 is fine and it should not throw when using EF6 because EF6 EF.dll does not depend on System.Data.Entity.dll at all but rather has its own code to handle edmx. Before EF6 edmx was handled by System.Data.Entity.dll which knew only v2 in .NET Framework 4 and v3 in .NET Framework 4.5. EF6 Tooling was rewritten to internally use EF6 EF.dll for all it does (even if the project is targeting EF5) and therefore is able to handle v3 edmx when the project is using EF6 and targeting .NET Framework 4. Some details here: http://bit.ly/1qqJBRD – Pawel Sep 17 '14 at 22:01
  • 3
    Note for those on VS 2012 there is a separate install that's required if you want to keep a .Net 4 project on edmx v3. [Entity Framework 6 Tools for Visual Studio 2012](http://www.microsoft.com/en-au/download/details.aspx?id=40762) – Jeff Jan 27 '15 at 02:09
2

For what its worth I switched the target framework back to 4.5, recompiled the solution, got a bunch of errors, switched it back to 4.0 and got the message:

"Successfully rebuilt the edmx for the new target framework"

From there I was able to recompile without any namespace errors shrug

Bauhaus
  • 509
  • 8
  • 22
2

Note for those on VS 2012 there is a separate install that's required if you want to keep a .Net 4 project on edmx v3. Entity Framework 6 Tools for Visual Studio 2012 – Jeff Jan 27 at 2:09

The above comment from Pawel's answer fixed my problem. I am copying it out into its own answer so that people can find it.

Bakanekobrain
  • 423
  • 6
  • 14