oracle 实体框架:指定的架构无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20542026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Entity Framework : Schema specified is not valid
提问by NMathur
I am developing a web application that is using Entity Freamwork 5 Visual Studio 2012 and it need to support both SQL Server and Oracle database providers. I created entity model for Oracle Database. I thought it would work after some changes in connectionstrings, bu no it is not that easy .. I found this post:
我正在开发一个使用 Entity Freamwork 5 Visual Studio 2012 的 Web 应用程序,它需要同时支持 SQL Server 和 Oracle 数据库提供程序。我为 Oracle 数据库创建了实体模型。我认为它会在连接字符串中进行一些更改后起作用,但不是那么容易..我发现了这篇文章:
http://www.codeproject.com/Articles/82017/Preparing-an-Entity-Framework-model-for-multi-prov
http://www.codeproject.com/Articles/82017/Preparing-an-Entity-Framework-model-for-multi-prov
Now I am getting following error
现在我收到以下错误
Schema specified is not valid. Errors: my_s_entity.ssdl(2,12) : warning 0005: Could not find schema information for the attribute 'Version'. my_s_entity.ssdl(2,2) : error 0010: The element Edmx in namespace http://schemas.microsoft.com/ado/2009/11/edmxwas unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm/ssdl, http://schemas.microsoft.com/ado/2009/02/edm/ssdl, http://schemas.microsoft.com/ado/2009/11/edm/ssdl.
指定的架构无效。错误:my_s_entity.ssdl(2,12):警告 0005:找不到属性“版本”的架构信息。my_s_entity.ssdl(2,2):错误 0010:命名空间http://schemas.microsoft.com/ado/2009/11/edmx 中的元素 Edmx对于根元素是意外的。以下命名空间之一中的预期架构:http://schemas.microsoft.com/ado/2006/04/edm/ssdl、 http://schemas.microsoft.com/ado/2009/02/edm/ssdl、 http://schemas.microsoft.com/ado/2009/11/edm/ssdl。
Stack trace:
堆栈跟踪:
[MetadataException: Schema specified is not valid. Errors:
my_s_entity.ssdl(2,12) : warning 0005: Could not find schema information for the attribute 'Version'.
my_s_entity.ssdl(2,2) : error 0010: The element Edmx in namespace http://schemas.microsoft.com/ado/2009/11/edmx was unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm/ssdl, http://schemas.microsoft.com/ado/2009/02/edm/ssdl, http://schemas.microsoft.com/ado/2009/11/edm/ssdl.]
System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +965
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +105
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +83
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Control.PreRenderRecursiveInternal() +168
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
I have searched on web but not able to fine any solution. Why I am getting this issue? If anyone have every faced same and have any solution please share.
我在网上搜索过,但无法找到任何解决方案。为什么我会遇到这个问题?如果有人遇到相同的情况并有任何解决方案,请分享。
回答by Alper ?ald?rak
Add a project reference to EntityFramework.SqlServer.dll
添加项目引用 EntityFramework.SqlServer.dll
回答by Kelum Priyadarshane
I had this error, This solutionworks for me
我有这个错误,这个解决方案对我有用
public MyContext : DbContext
{
public MyContext() : base("name=MyContext")
{
// the terrible hack
var ensureDLLIsCopied =
System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}
回答by Shiraz Bhaiji
If you open Your edmx file in the xml editor it should look like this:
如果您在 xml 编辑器中打开您的 edmx 文件,它应该如下所示:
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
<edmx:Runtime>
<edmx:StorageModels>
<Schema Namespace="XXX.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2008" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
There is a relationship between the xmlns namespace and the Version of EF you are using. There is some mismatch in the EF Version you created the model With and where you are trying to use it.
xmlns 命名空间与您使用的 EF 版本之间存在关系。您创建模型的 EF 版本与您尝试使用它的位置存在一些不匹配。