实体框架 - 无法加载指定的元数据资源 [英] Entity Framework - Unable to load the specified metadata resource

查看:148
本文介绍了实体框架 - 无法加载指定的元数据资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意识到这已经被问了很多次,但我似乎无法得到我的问题的底线。我收到以下错误堆栈:





当我反映出我的dll,我可以看到以下





阅读



但是修复程序似乎没有帮助,我不能在服务器上安装.NET 4.5。

解决方案

p>所以我已经到底了,部分我认为这是我的错。



无法加载指定的元数据资源问题 p>

这是因为我将edmx模型上的元数据人工处理设置设置为EntityDeploy到Embedded Resouce。



所以这意味着它只是将整个edmx文件文件嵌入到dll中,而不是生成ssdl,msl和csdl文件。



我想你必须将其设置为EntityDeploy才能正常工作并生成这些文件。无法解析程序集DllName.dll



这是由Andrew在上面的评论中解决的,谢谢你的指针。



找不到要嵌入的概念模式节点一个输入文件的资源



这个整个问题的关键是这个,我们的构建服务器目前在Windows 2003上,所以不能有.NET 4.5安装,本地我们使用EF 6.1在VS2013上的.NET 4.0下运行。



但由于某种原因,我们需要在我们的构建中安装.NET 4.5即使我们没有使用4.5的任何功能,也没有使用.NET 4框架来完成此操作。



降级到EF到4.3在短期内为我们解决了这个问题。不理想,但它有效。


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 obj\Debug\edmxResourcesToEmbed 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.

解决方案

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.

这篇关于实体框架 - 无法加载指定的元数据资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆