title: Timeout issue with PostgreSQL and Entity Framework
body: <p>When I try to query a PostgreSQL database through <code>EntityFramework6.Npgsql</code> with the following code:</p>
  
  <pre><code>using (MyDbContext context = new MyDbContext())
  {
     var res = (from b in context.mytable select new { b.Name, b.Age }); 
     foreach (var row in res)
     {
        Console.WriteLine(row.Name + " - " + row.Age);
     }
  }
  </code></pre>
  
  <p>I get a timeout exception after fetching few lines with the following error:</p>
  
  <blockquote>
    <p>[Npgsql.NpgsqlException] : {"57014: canceling statement due to
    statement timeout"} </p>
    
    <p>Message: 57014: canceling statement due to
    statement timeout</p>
  </blockquote>
  
  <p>When I execute the same operation while fetching all the data to a List, the code works fine:</p>
  
  <pre><code>using (MyDbContext context = new MyDbContext())
  {
     var res = (from b in context.mytable select new { b.Name, b.Age }).ToList(); 
     foreach (var row in res)
     {
        Console.WriteLine(row.Name + " - " + row.Age);
     }
  }
  </code></pre>
  
  <p>I suspect that it is related to the way PostgreSQL manages its connection pool but I don't know how I could handle it correctly through Entity Framework.</p>