Entity Framework - Unable to load the specified metadata resource

前端 未结 17 1252
一生所求
一生所求 2020-12-14 15:21

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:

相关标签:
17条回答
  • 2020-12-14 15:58

    If you're using the dotnet CLI

    For newer visitors using the new dotnet build tooling to build Entity Framework 6.x based projects, know that it currently does NOT embed any metadata into the final build. So if you run from within VS it'll run, but if your CI scripts use dotnet then they will fail on the server until you switch back to msbuild. IMHO, this is a bug and the tools should handle this. You can chime on the GitHub thread if needed.

    0 讨论(0)
  • 2020-12-14 15:59

    The connection string "metadata=res" should be same as Edmx name. eg

    metadata=res://*/EmployeeModel.csdl 
    

    this EDMX name should be EmployeeModel

    0 讨论(0)
  • 2020-12-14 15:59

    I have used EF6 in my visual studio 2013. I have solved this by doing the following steps.

    • Right click on the Entity model
    • Open with XML(Text) editor
    • in tag set ProviderManifestToken="2008"
    • build solution

    Hope it works for you..

    0 讨论(0)
  • 2020-12-14 16:00

    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.

    0 讨论(0)
  • 2020-12-14 16:00

    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.

    0 讨论(0)
提交回复
热议问题