title: Entity Framework 6: Schema specified is not valid
body: <p>I have 4 following projects in my solution. All the projects use target framework version 4.0. </p>
  
  <ul>
  <li><code>1. Durabuilt.CantorERP.Entities</code> > Class library project > Used ADO.NET Entity Data Model to expose tables and views in SQL Database named CantorERP </li>
  <li><code>2. Durabuilt.Duranet2.Entities</code> >  Class library project > Used ADO.NET Entity Data Model to expose tables in SQL Database named DuranetTest</li>
  <li><code>3. Durabuilt.Duranet2.BL</code> >  Class library project > Contains business logic and references both of the above Entities projects for CRUD operations. All logic including CRUD resides in this project.</li>
  <li><code>4. Durabuilt.Duranet2.UI</code> > It is a website which is the UI and references Durabuilt.Duranet2.BL project.</li>
  </ul>
  
  <p>SQL Server version is 2005. Both the Databases CantorERP and DuranetTest reside on a database server. I connect to the database server from my development machine.</p>
  
  <p>Everything works fine on my development machine. When I deploy the UI project to our hosting server (Windows 2003 SP2 running IIS6 .net version 4.0). There are following three pages (<code>~/RAF/Common/NoChargeSearch.aspx</code>, <code>~/RAF/Common/RAFSearch.aspx</code>, <code>~RAF/Sales/CreateNoCharge.aspx</code>) in my UI project that give me error mentioned below. </p>
  
  <pre><code>Server Error in '/' Application.
  Schema specified is not valid. Errors: 
  Duranet2Model.csdl(2,9) : warning 0005: Could not find schema information for the attribute 'Namespace'.
  Duranet2Model.csdl(2,35) : warning 0005: Could not find schema information for the attribute 'Alias'.
  Duranet2Model.csdl(2,48) : error 0005: The 'http://schemas.microsoft.com/ado/2009/02/edm/annotation:UseStrongSpatialTypes' attribute is not declared.
  Duranet2Model.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.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors: 
  Duranet2Model.csdl(2,9) : warning 0005: Could not find schema information for the attribute 'Namespace'.
  Duranet2Model.csdl(2,35) : warning 0005: Could not find schema information for the attribute 'Alias'.
  Duranet2Model.csdl(2,48) : error 0005: The 'http://schemas.microsoft.com/ado/2009/02/edm/annotation:UseStrongSpatialTypes' attribute is not declared.
  Duranet2Model.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.
  
  Source Error: 
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Stack Trace: 
  
  
  [MetadataException: Schema specified is not valid. Errors: 
  Duranet2Model.csdl(2,9) : warning 0005: Could not find schema information for the attribute 'Namespace'.
  Duranet2Model.csdl(2,35) : warning 0005: Could not find schema information for the attribute 'Alias'.
  Duranet2Model.csdl(2,48) : error 0005: The 'http://schemas.microsoft.com/ado/2009/02/edm/annotation:UseStrongSpatialTypes' attribute is not declared.
  Duranet2Model.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.]
     System.Data.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError) +8617673
     System.Data.Metadata.Edm.EdmItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError) +139
     System.Data.Metadata.Edm.EdmItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) +158
     System.Data.Metadata.Edm.EdmMetadataEntry.LoadEdmItemCollection(MetadataArtifactLoader loader) +90
     System.Data.Metadata.Edm.EdmItemCollectionLoader.LoadItemCollection(EdmMetadataEntry entry) +12
     System.Data.Metadata.Edm.MetadataCache.LoadItemCollection(IItemCollectionLoader`1 itemCollectionLoader, T entry) +149
     System.Data.Metadata.Edm.MetadataCache.GetOrCreateEdmItemCollection(String cacheKey, MetadataArtifactLoader loader, Object&amp; entryToken) +141
     System.Data.EntityClient.EntityConnection.LoadEdmItemCollection(MetadataWorkspace workspace, MetadataArtifactLoader artifactLoader) +103
     System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections) +369
     System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() +29
     System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor) +205
     System.Data.Objects.ObjectContext..ctor(String connectionString) +23
     System.Web.UI.WebControls.EntityDataSourceView.ConstructContext() +467
     System.Web.UI.WebControls.EntityDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +76
     System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +97
     System.Web.UI.WebControls.ListControl.PerformSelect() +34
     System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
     System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
     System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e) +29
     System.Web.UI.Control.PreRenderRecursiveInternal() +103
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Control.PreRenderRecursiveInternal() +175
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
  </code></pre>
  
  <p>All other pages in the project work fine including the ones in same directories e.g. <code>~/RAF/Common/NoCharge.aspx</code>, <code>~/RAF/Common/RAF.aspx</code>, <code>~RAF/Sales/CreateRAF.aspx</code>. Interestingly <code>~/RAF/Common/RAFSearch.aspx</code> uses a method called <code>GetTopNRafs()</code> inside a class called <code>RAFSearch.cs</code> to display data on page load and it does not work. Another page <code>~/RAF/Sales/raf_pending_requests.aspx</code> uses <code>GetRafsByStatus()</code> method inside same class <code>RAFSearch.cs</code> to display data on page load and it works. Both methods get the data from DuranetTest DB using Durabuilt.Duranet2.Entities project and return <code>List&lt;RAF&gt;</code>.</p>
  
  <p>I have made sure that both my Entities project and UI project have same version of EntityFramework (version 6.1.3). </p>
  
  <p>I've tried removing and recreating the .edmx files in both Durabuilt.CantorERP.Entities and Durabuilt.Duranet2.Entities projects. I've tried deleting all tables and views from edmx and used option of "update model from Database" and re-added tables and views. I've also deleted and recreated both Durabuilt.CantorERP.Entities and Durabuilt.Duranet2.Entities projects. Not sure if I'm missing any critical information. Please let me know if additional info is needed and I can add the info as requested.</p>
  
  <p>I've read various articles with similar issues and upgrading the server to .net version 4.5 has seemed to solve the issue. But I currently do not have that option to upgrade .net version nor can I install SP3 on the server as it is running some other applications that would break. Kindly let me know what can be done to fix this error. Appreciate your help.</p>
  
  <p>Connection strings as requested:</p>
  
  <pre><code>&lt;connectionStrings&gt;
     &lt;add name="CANTORERPConnectionString" connectionString="Data Source=CANTORSERVER;Initial Catalog=CANTORERP;Integrated Security=False; User Id=XXXXXX; password=XXXXXX" providerName="System.Data.SqlClient" /&gt;
     &lt;add name="CantorERPEntities" connectionString="metadata=res://*/CantorERPModel.csdl|res://*/CantorERPModel.ssdl|res://*/CantorERPModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=CANTORSERVER;initial catalog=CANTORERP;persist security info=True;user id=XXXXXX;password=XXXXXX;MultipleActiveResultSets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;
     &lt;add name="DURANET2Entities" connectionString="metadata=res://*/Duranet2Model.csdl|res://*/Duranet2Model.ssdl|res://*/Duranet2Model.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=CANTORSERVER;initial catalog=DURANETTEST;persist security info=True;user id=XXXXXX;password=XXXXXX;multipleactiveresultsets=True;application name=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>I use <code>CANTORERPConnectionString</code> to run direct SQL queries against the DB. And both <code>CantorERPEntities</code> and <code>DURANET2Entities</code> are connection strings used by the Entities projects.</p>