Entity Framework 6 Error Unable to load the specified metadata resource

↘锁芯ラ 提交于 2019-12-10 01:21:41

问题


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>

回答1:


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...



回答2:


After creating the entity if the database edit, entity does not work

As long as the entity update

In this way:

If this method did not work

It is better to do:

  1. Remove this tag: <add name="MapeoModelContainer" ...
  2. Remove MapeoModel.edmx
  3. Add ADO.NET Entity Data Model

Then use the wizard to create a connection and entity

If this method did not work either send Inner exception



来源:https://stackoverflow.com/questions/25514844/entity-framework-6-error-unable-to-load-the-specified-metadata-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!