title: Unable to determine the provider name for provider factory of type 'Npgsql.NpgsqlFactory'
body: <p>I trying running a test project but I not have a success because have a fail with npgsql connection. I reinstalled Npgsql, Npgsql.EntityFramework, EntityFramwork... but the problem persist.
  Result Message:</p>
  <blockquote>
  <p>Método de teste TestUserControl.ControleBaseTest.TesteGetPermissoesUsuarioFixo gerou exceção:</p>
  <p>System.NotSupportedException: Unable to determine the provider name for provider factory of type 'Npgsql.NpgsqlFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.
  Result StackTrace:</p>
  </blockquote>
  <p>I have this app.config file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --&gt;
      &lt;section name=&quot;entityFramework&quot; type=&quot;System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot; requirePermission=&quot;false&quot; /&gt;
    &lt;/configSections&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.5&quot; /&gt;
    &lt;/startup&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.5&quot; /&gt;
    &lt;/startup&gt;
    &lt;entityFramework&gt;
      &lt;providers&gt;
        &lt;provider invariantName=&quot;System.Data.SqlClient&quot;     type=&quot;System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer&quot; /&gt;
        &lt;provider invariantName=&quot;Npgsql&quot; type=&quot;Npgsql.NpgsqlServices, Npgsql.EntityFramework&quot;&gt;    &lt;/provider&gt;
      &lt;/providers&gt;
      &lt;!--&lt;defaultConnectionFactory type=&quot;Npgsql.NpgsqlFactory, Npgsql&quot; /&gt;--&gt;
      &lt;defaultConnectionFactory type=&quot;Npgsql.NpgsqlConnectionFactory, Npgsql&quot; /&gt;
    &lt;/entityFramework&gt;
    &lt;system.data&gt;
      &lt;DbProviderFactories&gt;
        &lt;remove invariant=&quot;Npgsql&quot; /&gt;
        &lt;add name=&quot;Npgsql Data Provider&quot; invariant=&quot;Npgsql&quot; support=&quot;FF&quot; description=&quot;.Net Framework Data Provider for Postgresql&quot; type=&quot;Npgsql.NpgsqlFactory, Npgsql&quot; /&gt;
      &lt;/DbProviderFactories&gt;
    &lt;/system.data&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>And a DbConfig is...</p>
  <pre><code>public class CtxUser : DbContext
  {
      public CtxUser(string conexao) : base(conexao) { }
      public CtxUser(DbConnection conexao) : base(conexao, true) { }
  }
  </code></pre>
  <p>My Model...</p>
  <pre><code>[Serializable]
  [Table(&quot;mytable&quot;, Schema = &quot;public&quot;)]
  public class Users
  {
      [Key, Column(&quot;userid&quot;)]
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int UserId { get; set; }
  
      [Column(&quot;login&quot;)]
      public string Login { get; set; }
  
      [Column(&quot;password&quot;)] 
      public string Password { get; set; }
  }
  </code></pre>
  <p>My logical class...</p>
  <pre><code>private DbConnection Conexao { get; set; }
  public ControleBase(DbConnection connector)
  {
      if(conexao == null)
          throw new ArgumentException(&quot;blah blah&quot;, &quot;connector&quot;);
      Conexao = conexao;
  }
  
  public Usuarios GetUser(int id)
  {
      if(id &lt;= 0)
          throw new ArgumentException(&quot;blah blah&quot;);
      Users user;
      using (var ctx  = new CtxUser(Connection))
      {
          user = ctx.DbUser.Find(id);
      }
      return user;
  }
  </code></pre>
  <p>My test method...</p>
  <pre><code>[TestClass]
  public class ControleBaseTest
  {
      private DbConnection Conexao
      {
          get
          {
              var cnxBuilder = new NpgsqlConnectionStringBuilder
              {
                  Database = &quot;mydatabase&quot;,
                  Host = &quot;localhost&quot;,
                  Port = 5432,
                  UserName = &quot;postgres&quot;,
                  Password = &quot;postgres&quot;,
                  Enlist = true,
                  CommandTimeout = 30,
                  Timeout = 30,
                  Pooling = true,
                  MinPoolSize = 1,
                  MaxPoolSize = 20,
                  Compatible = new Version(2, 1),
                  PreloadReader = true
              };
              return new NpgsqlConnection(cnxBuilder);
          }
      }
      
      [TestMethod]
      public void TestGetUser()
      {
          IUserControl userControl = new ControleBase(Conexao);            
          var usuario = userControl.GetUsuario(9);
          Assert.IsNotNull(usuario);
      }
  }
  </code></pre>
  <p>Obvious, this test is only for test connection with Npgsql and linq, etc... for test a solution for the problem. Someone have a idea?</p>