Note that there are some explanatory texts on larger screens.

plurals
  1. POMetadataException - Unable to load the specified metadata resource?
    text
    copied!<p>I have a solution with two relevant projects. The first builds <em>My.exe</em>, and the second builds a class library <em>MyModel.dll</em> that contains only my EF model. </p> <p>I'm getting a <code>MetadataException</code> in my Model's VS-generated <code>ObjectContext</code> ctor. I've read through <a href="http://blogs.teamb.com/craigstuntz/2010/08/13/38628/" rel="nofollow">Troubleshooting Entity Framework Connection Strings</a>, but I still haven't been able to narrow down my problem.</p> <p>The offending constructor code:</p> <pre><code>public MyEntities() : base(@"name=MyEntities", "MyEntities") // MetadataException here { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/cc982042.aspx" rel="nofollow">Metadata Artifact Processing</a> is set to <code>EmbedInOutputAssembly</code>. When I open <em>MyModel.dll</em> in Reflector, I see:</p> <ul> <li>DataAccessLayer.MyModel.csdl</li> <li>DataAccessLayer.MyModel.msl</li> <li>DataAccessLayer.MyModel.ssdl</li> </ul> <p>I've tried setting <a href="http://msdn.microsoft.com/en-us/library/aa983962%28v=vs.71%29.aspx" rel="nofollow">Build Action</a> for my <em>app.config</em> to <code>None</code> and <code>Content</code>, and neither makes a difference. The config file contains:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;connectionStrings&gt; &lt;add name="MyEntities" connectionString="metadata= res://*/DataAccessLayer.MyModel.csdl| res://*/DataAccessLayer.MyModel.ssdl| res://*/DataAccessLayer.MyModel.msl; provider=Devart.Data.PostgreSql; provider connection string=&amp;quot; User Id=MY_USER; Password=MY_PASS; Host=127.0.0.1; Database=MY_DB; Persist Security Info=True&amp;quot;" providerName="System.Data.EntityClient" /&gt; &lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre> <p>I've tried replacing the resource prefix <code>res://*/</code> with both <code>res://MyModel.dll/</code> and <code>res://MyModel/</code>, leaving the rest intact (because it matches the resources in <em>MyModel.dll</em>), but neither solved the problem. My class library is <a href="http://msdn.microsoft.com/en-us/library/ms227566%28v=vs.80%29.aspx" rel="nofollow">strong-named</a>.</p> <p>Both my executable and class library projects contain references to <code>System.Data.Entity</code> and <code>Devart.Data.PostgreSql</code>, and <em>My.dll</em> is being built to the same location as <em>My.exe</em>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload