title: How to use Entity Framework + PostgreSQL from connection?
body: <p>I have already seen threads discussing the use of Entity Framework and PostgreSQL with official instructions. Those instructions need to run <code>gacutil</code> for every install which is not so handy for deployment purposes.</p>
  
  <p>What I want to do here is passing PostgreSQL connection directly to the <code>DbContext</code> constructor. This is enough for me because I am going to use <code>CodeFirst</code> without designer. This is what I do:</p>
  
  <pre><code>public class Context : DbContext
  {
      Context(System.Data.Common.DbConnection connection)
          : base(connection, true)
      {
      }
  
      public static Context CreateContext()
      {
          NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=********;Database=xxx;");
          conn.Open();
  
          return new Context(conn);
      }
  }
  </code></pre>
  
  <p>But using this method I get a <code>NotSupportedException</code> with message:</p>
  
  <blockquote>
    <p>Unable to determine the provider name for connection of type
    'Npgsql.NpgsqlConnection'.</p>
  </blockquote>
  
  <p>What should I do?</p>