Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
548 views
in Technique[技术] by (71.8m points)

c# - Entity Framework - 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:

enter image description here

When I reflect out my dll I can see the following

enter image description here

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??

enter image description here

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...