title: Trouble with metadata in Entity Framework connection string
body: <p>I have a Silverlight 4 app using RIA Services in which I moved all of the RIA Services-specific code to a separate module (a WCF RIA Services class library) called "AppServices". Let's call the main app "Silverlight4App". I need to authenticate the users against a different database than the database where the rest of the data is stored. I have added an EF model to AppServices.Web, which is also where the authentication service currently resides. The Web.config file is in the main app, i.e. in Silverlight4App.  </p>
  
  <p>In the connectionStrings section of the web.config file, I originally had this:</p>
  
  <pre><code>&lt;add name="AuthEntities" connectionString="metadata=res://*/AuthModel.csdl|res://*/AuthModel.ssdl|res://*/AuthModel.msl;provider=... /&gt;
  </code></pre>
  
  <p>and I got the following error: </p>
  
  <p>"Load operation failed for query 'GetUser'. Unable to load the specified metadata resource."</p>
  
  <p>Then I tried various things such as:</p>
  
  <pre><code>&lt;add name="AuthEntities" connectionString="metadata=..\..\bin\AuthModel.csdl|..\..\bin\AuthModel.ssdl|..\..\bin\AuthModel.msl;provider=... /&gt;
  </code></pre>
  
  <p>and got this error:</p>
  
  <p>"Load operation failed for query 'GetUser'. The specified metadata path is not valid. A valid path must be either an existing directory, an existing file with extension '.csdl', '.ssdl', or '.msl', or a URI that identifies an embedded resource." </p>
  
  <p>I also tried copying the metadata files to various locations. In the end, I got a little further with the following.  </p>
  
  <pre><code>&lt;add name="AuthEntities" connectionString="metadata=~\..\..\..\Silverlight4App.Web\Metadata\AuthModel.csdl|~\..\..\..\Silverlight4App.Web\Metadata\AuthModel.ssdl|~\..\..\..\Silverlight4App.Web\Metadata\AuthModel.msl;provider=... /&gt;
  </code></pre>
  
  <p>With the above connection string, I got the following error:</p>
  
  <p>"Load operation failed for query 'GetUser'. The supplied connection string is not valid, because it contains insufficient mapping or metadata information.\r\nParameter name: connectionString Inner exception message: Unable to determine application context. The ASP.NET application path could not be resolved." </p>
  
  <p>Well, at least it seems to have <em>found</em> the metadata files!  Out of frustration I finally tried simply hard-coding the entire path to the metadata files: </p>
  
  <pre><code>&lt;add name="AuthEntities" connectionString="metadata=C:\Users\...\Silverlight4App.Web\Metadata\AuthModel.csdl|C:\Users\...\Silverlight4App.Web\Metadata\AuthModel.ssdl|C:\Users\...\Silverlight4App.Web\Metadata\AuthModel.msl;provider=... /&gt;
  </code></pre>
  
  <p>It worked perfectly!!  Unfortunately, it's a <strong><em>lousy</em></strong> solution, especially when I go to deploy the application.  </p>
  
  <p>It seems odd that the attempt that I tried just before the hard-coded attempt (see above) complained that there was insufficient information and yet the hard-coded attempt, which pointed to the <em>exact same files</em>, appears to contain sufficient information. Hmm...</p>
  
  <p>Any ideas?  I could surely use some help! </p>