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

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

问题描述

我在我的解决方案利用实体框架6模式第一,我分开我的数据模型类到另一个项目,这样我就可以到数据模型类添加引用不暴露我的数据模型上下文和连接。
我不想暴露我的实体数据模型项目(尤其是DB上下文等),以我的UI层。我有这样的:





现在我已经成功分离从我的数据模型我的自动生成的实体类,我试了一下这个通过添加一个实体或属性的实体项目Mapeo更新.BusinessEntity。



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

 <&是connectionStrings GT; 
<添加名称=MapeoModelContainer的connectionString =元数据= RES://*/MapeoModel.csdl |高分辨率://*/MapeoModel.ssdl |高分辨率://*/MapeoModel.msl;供应商=系统.Data.SqlClient;提供连接字符串=安培; QUOT;数据源= raranibar\ral;初始目录= Mapeo;用户ID = SA;密码= *****; MultipleActiveResultSets = TRUE;应用=&的EntityFramework放大器; QUOT;的providerName =System.Data.EntityClient/>
< /&是connectionStrings GT;

在我的服务层我其复制这个连接字符串App.config中,我的问题是这样的,当我想补充一个数据我有这样的消息:?无法加载指定的元数据资源我怎样才能解决这个问题。





更新
我找到了解决办法,我改变了的ConnectionString在App.Config中我在连接strign改为*为的DataModel的在我的情况(Mapeo.DatabaseModel)目录中的pretentation层,这是现在我的层连接字符串介绍:

 <&是connectionStrings GT; 
<添加名称=MapeoModelContainer的connectionString =元数据= RES://Mapeo.DatabaseModel/MapeoModel.csdl |高分辨率://Mapeo.DatabaseModel/MapeoModel.ssdl |高分辨率://Mapeo.DatabaseModel/MapeoModel .msl;提供商= System.Data.SqlClient的;提供连接字符串=安培; QUOT;数据源= raranibar\ral;初始目录= Mapeo;用户ID = SA;密码= scugua; MultipleActiveResultSets = TRUE;应用=&的EntityFramework放大器; QUOT ;的providerName =System.Data.EntityClient/>
< /&是connectionStrings GT;


解决方案

用正确的路径更新您的connectionString如果你这样类似的问题加载元数据文件。它可以帮助别人...

 的connectionString =元数据= 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天全站免登陆