title: Entity Framework 6 with Npgsql
body: <p>I want to use Entity Framework 6 with PostgreSQL in ASP.NET MVC 4 project. I got Entity Framework 6.0.2 + Npgsql 2.0.14.3, but I get error. How do I fix this?</p>
  <p>Error:</p>
  <blockquote>
  <p>An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code</p>
  <p>Additional information: The 'Instance' member of the Entity Framework provider type 'Npgsql.NpgsqlServices, Npgsql, Version=2.0.14.3, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see <a href="http://go.microsoft.com/fwlink/?LinkId=260882" rel="noreferrer">http://go.microsoft.com/fwlink/?LinkId=260882</a> for more information.</p>
  </blockquote>
  <p>Web.config</p>
  <pre><code>&lt;system.data&gt;
    &lt;DbProviderFactories&gt;
      &lt;add name=&quot;Npgsql Data Provider&quot;
          invariant=&quot;Npgsql&quot;
          description=&quot;Data Provider for PostgreSQL&quot;
          type=&quot;Npgsql.NpgsqlFactory, Npgsql&quot; /&gt;
    &lt;/DbProviderFactories&gt;
  &lt;/system.data&gt;
  &lt;connectionStrings&gt;
    &lt;add name=&quot;DatabaseContext&quot; connectionString=&quot;Server=localhost;port=5432;Database=main;User Id=postgres;Password=password;&quot; providerName=&quot;Npgsql&quot; /&gt;
  &lt;/connectionStrings&gt;
  &lt;entityFramework&gt;
    &lt;providers&gt;
      &lt;provider invariantName=&quot;Npgsql&quot; type=&quot;Npgsql.NpgsqlServices, Npgsql&quot; /&gt;
    &lt;/providers&gt;
  &lt;/entityFramework&gt;
  </code></pre>