Unable to load the specified metadata resource

I realise that this has been asked a number of times but I just can't seem to get the bottom of my issue. I'm getting the following error stack:

在这里输入图像描述

When I reflect out my dll I can see the following

Reading http://blogs.teamb.com/craigstuntz/2010/08/13/38628/ it suggests I'd expect to see the csdl, msl and ssdl files here, but they're not. They do exist here objDebugedmxResourcesToEmbed though.

Never-the-less I tried to explicitly tell the web.config where to look by doing this:

...connectionString="metadata=res://DllName.dll/PaymentModel.csdl|res://DllName.dll/PaymentModel.ssdl|res://DllName.dll/PaymentModel.msl;provider=System.Data.SqlClient;provider ... />

Which just throws an error saying it cannot find the dll:

Unable to resolve assembly 'DllName.dll'.

Very similar to this unresolved SO question Unable to resolve assembly Model.dll

The final thing I tried was to change the metadata line to:

...connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider ... />

This threw a message about sql ce which I'm not using - is there a way to get round this??

在这里输入图像描述

Is there anything else I can try? Or can anyone see where I'm going wrong? Some extra detais:

  • Using EF 6 EDMX set to "Embedded Resource"

  • Copy to output directory:"Do not copy"

  • Metadata artifact processing: "Embed in output assembly"
  • Finally on this - if I set the EDMX from Embedded Resource to EntityDeploy then this will work locally but not build on the build server as it throws the exact same error as this SO question:

    Could not find the Conceptual Schema node to embed as a resource for input file

    But the fix doesn't seem to help and I can't install .NET 4.5 on the server unfortunately.


    I have had the same problem. After moving .edmx file with EF model to separate assembly mentioned error caused my headache: "Unable to load the specified metadata resource".

    EF version 6.1

    Solution:

    Old value:

    metadata=res://*/Data.DataModel.csdl
    

    New value:

    metadata=res://*/DataModel.csdl
    

    Initially .edmx was under project's folder and I have moved it into project's root.


    So I've got to the bottom of this, partly I think this was my fault. I'll put solutions to each issue I encountered below in case it helps anyone else.

    Unable to load the specified metadata resource issue

    This was caused by me setting the 'Metadata Artifact Processing' setting on the edmx model from "EntityDeploy" to "Embedded Resouce".

    So this meant it just embedded the whole edmx file file into the dll and didn't generate the ssdl, msl and csdl files instead.

    I guess you have to set this to EntityDeploy for this to work and generate these files correctly. Makes perfect sense and our bad over here.

    Unable to resolve assembly 'DllName.dll'

    This was resolved by Andrew in the comments above, thanks for the pointer on that.

    Could not find the Conceptual Schema node to embed as a resource for input file

    The key to this whole issue really is this, our build server is currently on Windows 2003, so can't have .NET 4.5 installed, locally we were using EF 6.1 running under .NET 4.0 on VS2013.

    However for some reason it looks like we need to have .NET 4.5 installed on our build server to get this to build even though we're not using any of the 4.5 features and targetting the .NET 4 framework.

    Downgrading to EF to 4.3 solved this issue for us in the short term. Not ideal but it worked.


    you should specify the assembly fully qualified name and a path to your model file within it(separated by / ), not the dll name

    connectionString="metadata=res://Name.Of.The.Assembly, Culture=neutral, PublicKeyToken=8e2e51fcf4cf363e/Payment.PaymentModel.csdl|.........."
    

    the same for ssdl and msl

    链接地址: http://www.djcxy.com/p/38806.html

    上一篇: 无法加载指定的元数据资源Release vs Debug版本

    下一篇: 无法加载指定的元数据资源