NMathur
NMathur

Reputation: 829

Entity Framework : Schema specified is not valid

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:

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/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.

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 find any solution. Why I am getting this issue? If anyone have every faced same and have any solution please share.

Upvotes: 3

Views: 12539

Answers (3)

Kelum
Kelum

Reputation: 1775

I had this error, This solution works for me

public MyContext : DbContext
{
    public MyContext() : base("name=MyContext")
    {
        // the terrible hack
        var ensureDLLIsCopied = 
                System.Data.Entity.SqlServer.SqlProviderServices.Instance;   
    }

Upvotes: 1

Alper Şaldırak
Alper Şaldırak

Reputation: 1054

Add a project reference to EntityFramework.SqlServer.dll

Upvotes: 1

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65371

If you open Your edmx file in the xml editor it should look like this:

<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.

Upvotes: 0

Related Questions