EF with POCO templates and DbContext throws MetadataException when installed on server RRS feed

  • Question

  • I've a web application with two assemblies that both uses entity framework with POCO templates (with DbContext). When running in Visual Studio 2010 everything works perfect, but when I install the whole application on our development server (windows 2008 with IIS 7) the aspx pages which uses the first assembly with EF works fine, but the pages with the second assembly throw the following error:

    System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.MetadataException: Schema specified is not valid. Errors: Library.csdl(2,9) : warning 0005: Could not find schema information for the attribute 'Namespace'. Library.csdl(2,34) : warning 0005: Could not find schema information for the attribute 'Alias'. Library.csdl(2,2) : error 0010: The element Schema in namespace was unexpected for the root element. The expected Schema in one of the following namespaces:,, at System.Data.Metadata.Edm.EdmItemCollection.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModelOption, DbProviderManifest providerManifest, ItemCollection itemCollection, Boolean throwOnError)

    The strange thing is that the first assembly is working fine, but the second not. I've created the whole EF model (edmx with templates) from scratch again but I'm still getting the same error. I tried to build separate metadata files (csdl, msl and ssdl) in the output directory and use that files from the connectionstring, but I'm still getting the same error. The first connectionstring is for the model which is not working, the second works as expected:

    <add name="LibraryEntities" connectionString="metadata=res://AT.RiAxion.Library/Entities.Library_Model.csdl|res://AT.RiAxion.Library/Entities.Library_Model.ssdl|res://AT.RiAxion.Library/Entities.Library_Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data;initial catalog=ATNed_RiAxionLibraries_v5;persist security info=True;User ID=****;Password=****;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
    <add name="CustomerEntities" connectionString="metadata=res://AT.RiAxion/Customer.Customer.csdl|res://AT.RiAxion/Customer.Customer.ssdl|res://AT.RiAxion/Customer.Customer.msl;provider=System.Data.SqlClient;provider connection string=&quot;data;Initial Catalog=ATNed_Develop_v52_UT;Persist Security Info=True;User ID=****;Password=****;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>

    I think the connectionstrings are correct cause the files are found (when I change something I get a error that the files cannot be found).

    I found issues similar to this one but not with this part of the error:

    Could not find schema information for the attribute 'Namespace'

    Does somebody have an idea what the problem can be?


    Wednesday, March 14, 2012 1:45 PM


All replies

  • Hi Frank,


    According to your description, the two assemblies work in VS2010 but deloyment, right? I think you should ensure the right position for your config file and check the settings to see if they are same(Platform target and so on).

    Have a nice day.

    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 15, 2012 6:45 AM
  • Hi Alan,

    Thanks for your reply. I've made an exact copy of my visual studio project and copied it to our development server, With exact the same settings. The same database is used. The only difference is that Visual Studio uses the ASP.NET Development Server and the copy on the development server uses IIS 7 on Windows Server 2008. The application self is running fine for some years on IIS 6 and IIS 7. That's before we used some Entity Framework models. Another EF model in the same application is working correct. Could it be something with the names of the assemblies or namespaces perhaps? I know there are problems with using the same entity names in a different namespace, that's why we created a new assembly (AT.RiAxion.Library). We renamed (prefixed) all entities too, to be sure there are no conflicts with the entity names. Now we have the AT.RiAxion.Library assembly with a model named Library.edmx (in the namespace AT.RiAxion.Library) and an assembly named AT.RiAxion with a folder names Customer and in the folder a model named Customer.edmx (in the namespace (AT.RiAxion.Customer). Each with some entities in it.

    I'm seriously thinking about getting back my old working LinqToSql model if I can't get it work.

    Thursday, March 15, 2012 8:17 AM
  • Update:

    I removed my assembly and created a new one again. This time I've used another name for every class/object/entity. I didn't use the POCO entitities but used the normal creation of the edmx file, so now it's using ObjectContext instead of DbContext. But again I get exactly the same error (with the changed object names of course).

    Are there any other suggestion I can try to fix the problem?


    Next update:

    My collegue created a test with a new clean webapplication. When using the EntityDataSource we get the same error. When we don't use the EntityDataSource we don't get the error. The occurs only when installing it on our development server. So in my opinion there are two possibilities:

    • We are missing something on our server regarding to the EntityDataSource, or
    • There is a bug in the EntityDataSource

    I hope the first one. Anybody an idea what I can look for? We installed all latest windows updates and restarted the server multiple times.

    Next update:

    When we change the target framework to ".NET Framework 4" the EntityDataSource is working. When we leave it on "Microsoft Entity Framework June 2011 CTP" the EntityDataSource is not working. When I look in the list for installed application I see the following:

    So it looks like the June CTP components are installed correctly.

    Tuesday, March 20, 2012 10:30 AM
  • I posted this issue later on stackoverflow and found the solution!

    Reinstalling the June CTP solved the problem.

    Thursday, March 22, 2012 8:55 AM