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

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

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/689355/metadataexception-unable-to-load-the-specified-metadata-resource">MetadataException:无法加载指定的元数据资源

我希望有人能够帮助这一点。我曾尝试下面就到这里其他职位和数十个其他网站上,但我能得到这个工作。

I hope someone can help with this. i have tried following other posts on here and dozens on other sites but i can get this working.

实体框架是所有的工作,然后第二天刚开始给我的错误:无法加载指定的元数据资源。在实体类的构造函数。

the entity framework was all working, then the next day just started giving me the error: Unable to load the specified metadata resource. on the constructor of the entities class.

我检查了连接字符串,删除并重新添加的一切,但我仍然无法得到这个工作。

I have checked the connection strings, deleted and re added everything but i still cant get this working.

我的模型命名空间是WraithNath.co.uk.Models

my model namespace is WraithNath.co.uk.Models

中的元数据artificat被嵌入汇编

the metadata artificat is embed in assembly

我的连接字符串如下:

<add name="ConnectionString" connectionString="Data Source=.\SQL2008;AttachDbFilename=|DataDirectory|\WraithNath.co.uk.mdf;Integrated Security=True;" providerName="System.Data.SqlClient" />
   <add name="Entities" connectionString="metadata=res://*/Models.WraithNath.co.uk.csdl|res://*/Models.WraithNath.co.uk.ssdl|res://*/Models.WraithNath.co.uk.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQL2008;AttachDbFilename=|DataDirectory|\WraithNath.co.uk.mdf;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

我找不到了3个文件,我需要在装配时,它在反射寻找。

I cant find the 3 files i need in the assembly when looking at it in Reflector.

有没有一步一步的指导,排序了这一点?我已经尝试在搜索结果'实体框架无法加载指定的元数据资源第3页谷歌的每一个环节。

Is there a step by step guide to sort this out? i have already tried every link on the first 3 pages of google for search results 'entity framework Unable to load the specified metadata resource'.

推荐答案

克雷格斯顿茨写了一个广泛的(在我看来)的博客文章上解决此确切的错误信息,我个人会从那里开始。

Craig Stuntz has written an extensive (in my opinion) blog post on troubleshooting this exact error message, I personally would start there.

下面的资源:(资源)引用必须指向你的模型

The following res: (resource) references need to point to your model.

<add name="Entities" connectionString="metadata=
    res://*/Models.WraithNath.co.uk.csdl|
    res://*/Models.WraithNath.co.uk.ssdl|
    res://*/Models.WraithNath.co.uk.msl;

请确保每一个有你的.edmx文件名后的* /,用EDMX更改为扩展名的RES(.csdl,.ssdl,或.msl)。

Make sure each one has the name of your .edmx file after the "*/", with the "edmx" changed to the extension for that res (.csdl, .ssdl, or .msl).

这也可以帮助使用指定的程序集,而不是//*/".

It also may help to specify the assembly rather than using "//*/".

最坏的情况下,可以检查一切(有点慢,但应该总能找到资源),通过使用

Worst case, you can check everything (a bit slower but should always find the resource) by using

<add name="Entities" connectionString="metadata=
        res://*/;provider= <!-- ... -->

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

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