locked
Unable to load the specified metadata resource. RRS feed

  • Question

  • Hi,

     

    I am trying to create a framework for one of my new project using Entity Framework, WCF, WF and MVC. Presently i am stuck with an error "Unable to load the specified metadata resource."

    To make understand the different layers:

    I have a layer "TestArchitecture.BusinessEntities" where exists an Entity Model named "EntityModel.edmx".

    The BusinessEntities layer is referenced by "TestArchitecture.DAL" layer, which both are in turn referenced by "TestArchitecture.Service" layer.

    I have made client connection of the services in "TestArchitecture.UI" layer.

    The code gets build and once i run the code from the UI layer just to add a value in the Database; I see myself moving from the UI Layer to Service Layer and then to DAL Layer and then to Business Entities layer. Once it reaches BE layer it knocks me off with the error message in autogenerated file "EntityModel.Designer.cs" in the constructor

    ----------------------

    public WFTestEntities() :

    base("name=WFTestEntities", "WFTestEntities")

    {

    this.OnContextCreated();

    }

    --------------------

    The error thrown is "Unable to load the specified metadata resource."

     

    I have already read through many readings and posts and have checked the connection string. The connection string has been copied (manually) from the "app.config" file of BE layer to "web.config" layer of Service Layer and UI layer. The connection string is pasted below for your perusal:

    --------------------------------

    <configuration>

    <connectionStrings>

    <add name="WFTestEntities" connectionString="metadata=res://*/WFTestModel.csdl|res://*/WFTestModel.ssdl|res://*/WFTestModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=localhost;Initial Catalog=WFTest;Integrated Security=True;MultipleActiveResultSets=True'" providerName="System.Data.EntityClient" />

    </connectionStrings>

    </configuration>

    --------------------------------

    I hae checked the connection string and everything seems to be quite good.

     

    I would also like to add that:

    a.) I have checked the assembly file using the .Net reflector to make sure that the three files ".ssdl", ".csdl" and ".msl" files exist.

    b.) Also the "Embed in Output Assembly" property of "EntityModel.edmx" file is to set to "Embed in Output Assembly", while "Build Action" property has been set to "EntityDeploy".

    c.) I have also tried setting the  "Build Action" to "Embedded Resource" but of no use.

     

    Any help would be quite thankful.

    Friday, November 21, 2008 11:24 AM

Answers

  • Hi,

    It seems I have been able to resolve the issue I was facing with.

     

    After doing all reasearch for nearly 3-4 hours I could not find any origination of error. Frustated, I deleted the Model file and the app.config file. Once deleted, I created them again, and it is now working.

    I donot know why this hapenned, but somehow it is working.

     

     

     

    Friday, November 21, 2008 12:39 PM

All replies

  • Hi,

    It seems I have been able to resolve the issue I was facing with.

     

    After doing all reasearch for nearly 3-4 hours I could not find any origination of error. Frustated, I deleted the Model file and the app.config file. Once deleted, I created them again, and it is now working.

    I donot know why this hapenned, but somehow it is working.

     

     

     

    Friday, November 21, 2008 12:39 PM
  • Is this the fix, then ? I have the same problem. IT appears as if the EDMX has gotten corrupted twice already,  my changes including changing the namespace in the designer file as well as adding a stored procedure to populate an entity. . I do have the most luck if I know all my tables a head of time and start fresh with a new EDMX.
    Tuesday, August 11, 2009 4:43 PM
  • Hi guys.  The problem is not that your EDMX file became corrupted but that your connection string values need to be recreated from the tool.  I found this same problem happened when I moved an EDMX file from one project to another.  To fix this issue open up the EDMX file in your designer, then right click and select Generate Database from model..., hit the previous button, select your connection or make a new one (make sure save entity connection settings in web.config is checked), and then finish the process.

    This will regnerate the DDL script and recreate the connection string in the web.config file.  You DO NOT have to actually run the script and recreate the database tables.  This process should fix your EDMX without having to recreate the model from the database or from scratch.

    Hope this helps you guys out in the future.

    • Proposed as answer by Bryan DeYoung Friday, December 16, 2011 2:23 AM
    Tuesday, November 22, 2011 4:28 PM
  • I ran into the same problem and thought I would share what action I took that caused the metadata information to suddenly be invalid.  In my multi-project solutions, I tend to follow a pattern of locating common functionality and data access layer functionality each in separate projects.  From that point I reference those in any dependent projects.

    Initially, I created my entities model (*.edmx) in the root directory of the the "common" functionality project.  Later I relocated the entities model to a completely separate project that I intended to use to provide my data access layer classes/components.  This would have likely caused no issues in itself except that I changed the namespaces for the classes in this project to denote that they were a part of the data access layer.  This is where the break happened.  Refactoring the namespace in the class files did not result in the namespace information contained in the entities model metadata getting updated.

    I noticed it when I followed the recommendation of bsfiosco above and compared the metadata connection string that I had originally with the new connection string created by the IDE.  As soon as I replaced the connection string in my client application app.config file, the issue disappeared. 

    I'm including the before and after metadata strings for relevance and have highlighted the section where the issue was.  I believe this is caused because I have the property Metadata Artifact Processing set to "Embed in Output Assembly" for the entities model and the internal embedded resource path was incorrect.

    1) Invalid metadata metadata=res://*/EntitiesData.csdl|res://*/EntitiesData.ssdl|res://*/EntitiesData.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=serverName;Initial Catalog=databaseName;Integrated Security=True;MultipleActiveResultSets=True&quot;

    2) Correct metadata metadata=res://*/Data.EntitiesData.csdl|res://*/Data.EntitiesData.ssdl|res://*/Data.EntitiesData.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=serverName;Initial Catalog=databaseName;Integrated Security=True;MultipleActiveResultSets=True&quot;

    • Proposed as answer by wagonerr Thursday, March 15, 2012 4:54 PM
    Friday, December 16, 2011 2:44 AM