title: Using Entity Framework as a Web Part's Data Source in Sharepoint 2010
body: <p>I have a very simple web part.  I have a single grid view, which I am populating using linq to entities (or at least that's what I want to do).  The Entity Data Model .edmx file is located in the same project as the web part, and everything looks to be in working order.  When I debug the project, it blows up on the entity model constructor with the error message: </p>
  
  <blockquote>
    <p>The specified named connection is
    either not found in the configuration,
    not intended to be used with the
    EntityClient provider, or not valid.</p>
  </blockquote>
  
  <p>My connection string in the App.Config is as follows:</p>
  
  <pre><code>&lt;add name="MyDBEntities" connectionString="metadata=res://*/MyDBEntityModel.csdl|res://*/MyDBEntityModel.ssdl|res://*/MyDBEntityModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=True;MultipleActiveResultSets=True&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>The constructor:</p>
  
  <pre><code>public MyDBEntities() : base("name=MyDBEntities", "MyDBEntities")
  </code></pre>
  
  <p>So, from what I've read elsewhere, my problem is that SharePoint can't see my connection string.  Which means, that the App.Config from my project isn't actually getting loaded into SharePoint when I run/debug the project.  If that's the case, then how I do set my project up in Visual Studio 2010 to ensure SharePoint picks up the App.Config in addition to the master SharePoint config file.   If I have to manually copy the connection string, is there a "best practice" procedure for doing so?  Are SharePoint Web Parts combined with the Entity Framework just not ready for prime time?</p>