title: Configure npgsql to use with .NET 3.5 and EF
body: <p>I'm developing an application that uses third-party libraries working with .NET framework 3.5 (not newer). My application is WPF, and I need to use EntityFramework to connect to Postgre SQL database.</p>
  
  <p>I googled a bit and found that the most popular way to connect to Postgre is using npgsql provider.</p>
  
  <p>So, I tried to install npgsql from their website and then found that exe installer only installs npgsql for .NET 4.0 and 4.5. It also installs vsix extension for Visual Studio which is working just fine. I had to download npgsql libraries for .NET 3.5 and added references to Npgsql.dll and Npgsql.EntityFrameworkLegacy.dll manually.</p>
  
  <p>I also set my application target framework to 3.5 and used Nuget to install EntityFramework (4.1.10715 is the latest version to work with .NET 3.5).</p>
  
  <p>Then I was able to connect to database using edmx wizard (which detected my Entityframework setup as '3.5') and generated edmx and some classes.</p>
  
  <p>SO, the problem is, when I try to fetch some data in my application like this:</p>
  
  <pre><code>using (var db = new Entities())
  {
      var list = db.MyItems.ToList()
  }
  </code></pre>
  
  <p>it always fails with error:</p>
  
  <blockquote>
    <p>The specified store provider cannot be found in the configuration, or
    is not valid.</p>
  </blockquote>
  
  <p>I configured my App.config this way:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
  &lt;configSections&gt;
      &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt;
  &lt;/configSections&gt;
  &lt;entityFramework&gt;
      &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt;
          &lt;parameters&gt;
              &lt;parameter value="v11.0" /&gt;
          &lt;/parameters&gt;
      &lt;/defaultConnectionFactory&gt;
      &lt;providers&gt;
          &lt;provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" /&gt;
      &lt;/providers&gt;
  &lt;/entityFramework&gt;
  &lt;startup&gt;
      &lt;supportedRuntime version="v2.0.50727" /&gt;
  &lt;/startup&gt;
  &lt;connectionStrings&gt;
      &lt;add name="myEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=Npgsql;provider connection string=&amp;quot;PORT=5432;TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE=2.2.5.0;DATABASE=mydb;HOST=localhost;PASSWORD=postgres;USER ID=postgres&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p></p>
  
  <p>I think I should change something in my App.config but cannot figure out what is wrong.</p>
  
  <p>Please help.</p>