Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade to EF6 on .net4 - System.Data.MetadataException: Schema specified is not valid

I have an asp.net website running under .net v4. I have upgraded from Entity Framework v5 to v6.02 and all worked fine running locally on IIS express and .net4 using the EntityFramework v4 dll provided by nuget.

I publish to my hosting company and get the error below. Upgrading to .net4.5 might help, but this is not an option on my provider at the moment.

Any suggestions?

System.Data.MetadataException: Schema specified is not valid. Errors: BkkpsModel.csdl(2,9) : warning 0005: Could not find schema information for the attribute 'Namespace'. BkkpsModel.csdl(2,32) : warning 0005: Could not find schema information for the attribute 'Alias'. BkkpsModel.csdl(2,98) : error 0005: The 'http://schemas.microsoft.com/ado/2009/02/edm/annotation:UseStrongSpatialTypes' attribute is not declared. BkkpsModel.csdl(2,2) : error 0010: The element Schema in namespace http://schemas.microsoft.com/ado/2009/11/edm was unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm, http://schemas.microsoft.com/ado/2007/05/edm, http://schemas.microsoft.com/ado/2008/09/edm.
like image 874
simon831 Avatar asked Jan 16 '14 03:01

simon831


2 Answers

You created an EDMX file with Entity Framework 6 but you using it with Entity Framework 5. Entity Framework 6 uses EDMX file with version 3.0 but Entity Framework 5 does not support it.

You must repair your EDMX file from version 3.0 to version 2.0

The easiest way to do that is open EDMX in Visual Studio 2012 project with Entity Framework 5 or older. The entity data model designer show error: unable to display file. The file references an XML namespace that is inconsistent with the target framework of the project. Than click the modify link and the designer automaticly repair your EDMX file.

OR:
1. open your EDMX file as XML Editor
2. change the following elements:

from:
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
to:
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">

from:
xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl"
to:
xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl"

from:
xmlns="http://schemas.microsoft.com/ado/2009/11/edm"
to:
xmlns="http://schemas.microsoft.com/ado/2008/09/edm"

from:
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
to:
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">

... for all inconsistent xmlns
like image 84
Cyrus Avatar answered Oct 08 '22 20:10

Cyrus


Another way of achieving what Cyrus said (downgrading from edmx v3 to ednx v2) is in the answer for another question:

EDMX .NET 4.5 to 4.0?

like image 34
MajorInc Avatar answered Oct 08 '22 22:10

MajorInc