title: WCF & Entity Framework & SQL Server - "The underlying provider failed on Open"
body: <p>I am successfully running tests through the the WCF Test Client, until I try to pull in data with Entity Framework.</p>
  
  <p>To make sure I'm not doing anything stupid, I downloaded the sample code from this tutorial, which is doing something similar: <a href="http://www.codeproject.com/KB/WCF/WCFandEF.aspx" rel="nofollow">http://www.codeproject.com/KB/WCF/WCFandEF.aspx</a></p>
  
  <p>...and when I run it, I get the same error in a similar place:</p>
  
  <pre><code>var productEntity = (from p in context.ProductEntities 
                       where p.ProductID == id
                       select p).FirstOrDefault();
  </code></pre>
  
  <p>The error is </p>
  
  <blockquote>
    <p>The underlying provider failed on Open.</p>
  </blockquote>
  
  <p>I can open the database fine from a "normal application" with the same connection string, it seems to be specific accessing the DB from the WCF test client.</p>
  
  <p>Research here and on Google for "The underlying provider failed on Open." usual indicates that it's a connection string problem, but I'm pretty sure it's not in this case.</p>
  
  <p>So now I expect it's some sort of permissions problem.</p>
  
  <p>I am using SQL Server and Windows 7, with visual studio 2010.</p>
  
  <p>I have been banging my head since yesterday, so any help or protective head gear appreciated.</p>
  
  <p><strong>Edited to include connection string</strong></p>
  
  <pre><code>&lt;add name="NorthwindEntities" 
       connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider
  connection string=&amp;quot;Data Source=localhost;Initial Catalog=Northwind;User ID=sa;MultipleActiveResultSets=True&amp;quot;" 
       providerName="System.Data.EntityClient" /&gt;
  </code></pre>