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

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

问题描述


可能重复:

MetadataException:无法加载指定的元数据资源


我希望有人可以帮助这个。我已经尝试过跟随其他帖子在这里和其他网站上几十个,但我可以得到这个工作。



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



我已经检查了连接字符串,删除并重新添加了所有内容,但我仍然无法使其正常工作。



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



元数据嵌入嵌入到组件中



我的连接字符串如下:

 < add name =ConnectionStringconnectionString =数据源= .\SQL2008; AttachDbFilename = | DataDirectory | \WraithNath.co.uk.mdf; Integrated Security = True; providerName =System.Data.SqlClient/> 
< add name =EntitiesconnectionString =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/>

在Reflector中查看它时,我无法找到我需要的3个文件。 >

有没有一步一步的指导来排序?我已经尝试google的前3页的每个链接搜索结果的实体框架无法加载指定的元数据资源。

解决方案

Craig Stuntz 已经广泛(在我看来)博客文章解决这个确切的错误信息,我个人将从那里开始。



以下 res:(资源)引用需要指向你的模型。

 < add name =EntitiesconnectionString =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)的扩展名。



它也可能有助于指定程序集而不是使用//*/\".



最糟糕的情况是,您可以使用

$ b $检查所有内容(有点慢,但应始终找到资源) b

 < add name =EntitiesconnectionString =metadata = 
res:// * /; provider =<! 。>


Possible Duplicate:
MetadataException: Unable to load the specified metadata resource

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.

my model namespace is WraithNath.co.uk.Models

the metadata artificat is embed in assembly

my connection strings are as follows:

<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" />

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

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;

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天全站免登陆