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

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

问题描述

我在我的解决方案中使用Entity Framework 6和model first,我将Data Model类分为另一个项目,以便我可以添加对Data Model类的引用,而不会暴露我的Data Model上下文和连接。
我不想将我的实体数据模型项目(特别是数据库上下文等)暴露给我的UI层。我有这个:





我现在已经将我的自动生成的实体类从我的数据模型中分离出来,我尝试通过在实体中添加一个实体或一个实体,在项目Mapio中更新.BusinessEntity。



这是DatabaseLayer(Mapeo.DatabaseModel)中的连接字符串

 <&的ConnectionStrings GT; 
< add name =MapeoModelContainerconnectionString =metadata = res://*/MapeoModel.csdl | res://*/MapeoModel.ssdl | res://*/MapeoModel.msl; provider = System .Data.SqlClient; provider connection string =& quot; data source = raranibar\ral; initial catalog = Mapeo; user id = sa; password = *****; MultipleActiveResultSets = True; App = EntityFramework& quot; providerName =System.Data.EntityClient/>
< / connectionStrings>

在我的服务层我把这个连接字符串复制到App.config,我的问题是这样我想添加一个数据我有这个消息:无法加载指定的元数据资源我如何解决这个问题?





已更新
我找到了解决方案,我改变了在App.Config中的connectionstring在我的case(Mapeo.DatabaseModel)的DataModel的目录中连接strign*中替换的预处理层这是现在我的层的连接字符串演示文稿:

 < connectionStrings> 
< add name =MapeoModelContainerconnectionString =metadata = res://Mapeo.DatabaseModel/MapeoModel.csdl | res://Mapeo.DatabaseModel/MapeoModel.ssdl | res://Mapeo.DatabaseModel/MapeoModel .msl; provider = System.Data.SqlClient; provider connection string =& quot; data source = raranibar\ral; initial catalog = Mapeo; user id = sa; password = scugua; MultipleActiveResultSets = True; App = EntityFramework& quot ; providerName =System.Data.EntityClient/>
< / connectionStrings>


解决方案

如果你有这样的话,像问题一样加载元数据文件。可以帮助别人...

  connectionString =metadata = res:// DatabaseModel / MyModel ... 


I'm using Entity Framework 6 and "model first" in my solution, I separated my "Data Model" classes into another project, so that I can add reference to the "Data Model" classes without exposing my "Data Model Contexts" and connections. I don't want to expose my Entity Data Model project (especially the DB Context etc) to my UI Layer. I have this:

I have now successfully separated my auto generated entity classes from my data model, I tried it this works by adding an entity or a property to an entity is updated in the project Mapeo.BusinessEntity.

This is my connection string from DatabaseLayer (Mapeo.DatabaseModel)

<connectionStrings>
   <add name="MapeoModelContainer" connectionString="metadata=res://*/MapeoModel.csdl|res://*/MapeoModel.ssdl|res://*/MapeoModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=raranibar\ral;initial catalog=Mapeo;user id=sa;password=*****;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

In my service layer I it copied this connection string to the App.config, my problem is this when I want to add a data I have this message: Unable to load the specified metadata resource How I can resolve this problem?

Updated I found the solution, I changed the connectionstring in App.Config the pretentation layer I replaced in the connection strign "*" for the directory of DataModel in my case (Mapeo.DatabaseModel) this is now my connection string in layer presentation:

  <connectionStrings>
     <add name="MapeoModelContainer" connectionString="metadata=res://Mapeo.DatabaseModel/MapeoModel.csdl|res://Mapeo.DatabaseModel/MapeoModel.ssdl|res://Mapeo.DatabaseModel/MapeoModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=raranibar\ral;initial catalog=Mapeo;user id=sa;password=scugua;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

解决方案

Update your connectionString with correct path if you've such like issue to load metadata files. May it help someone else...

connectionString="metadata=res://DatabaseModel/MyModel...

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

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