2014-01-16 29 views
5

我有一個運行在.net v4下的asp.net網站。 我已經從Entity Framework v5升級到v6.02,並且使用Nuget提供的EntityFramework v4 dll在IIS express和.net4本地運行良好。在.net4上升級到EF6 - System.Data.MetadataException:指定的模式無效

我發佈到我的託管公司,得到下面的錯誤。升級到.net4.5可能會有所幫助,但目前這不是我的提供商的選項。

有什麼建議嗎?

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. 

回答

10

您創建了一個EDMX文件與實體框架6,但你使用它與實體框架5. 實體框架6使用EDMX 3.0版本,但實體框架5不支持文件。

您必須修復3.0版本的EDMX文件版本2.0

做的是開放EDMX在Visual Studio 2012的項目與實體框架5或以上的最簡單方法。實體數據模型設計器顯示錯誤:無法顯示文件。該文件引用與項目的目標框架不一致的XML命名空間。單擊修改鏈接並設計器自動修復您的EDMX文件。

OR:
1.打開你的EDMX文件作爲XML編輯器
2.改變下列要素:

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 
+4

這發生在我身上,但我最後不得不升級我的EDMX到V3,所以按照反向這些步驟幫助我這樣做。謝謝! –

+0

我一直假定「修改」鏈接只是打開XML進行修改。我不知道它實際上會嘗試修復xml命名空間。我想我已經手動完成了十幾次...> _ < –

相關問題