title: The underlying provider failed on Open for Entity Framework
body: <p>First a disclaimer - I did my research on the topic and found <strong>plenty</strong> of material. Sadly, none of that was to any help, as each answer can be counted into the following categories.</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/4987787/entity-framework-giving-exception-the-underlying-provider-failed-on-open">Permission issues for accessing database</a></li>
  <li><a href="https://stackoverflow.com/questions/18161627/the-underlying-provider-failed-on-open-in-entity-framework-connection">Miscellaneous missconfigurations</a></li>
  <li><a href="https://stackoverflow.com/a/11794135/1525840">Incorrect garbage disposal</a></li>
  <li><a href="https://stackoverflow.com/a/22062877/1525840">Application of MultipleActiveResultSets</a></li>
  <li><a href="https://stackoverflow.com/a/12583431/1525840">Usage of <em>ToList()</em> indiscriminately</a></li>
  </ol>
  
  <p>My issue occurs only when fetching/executing larger sets, so we can eliminate (1) and (2). Since I can execute a number of queries in the same context getting the exception on fourth or fifth reading, we can eliminate (3). I've checked the connection string and (4) can't be the problem because the multiplicity is already enabled. The last candidate is (5) but it can be eliminated as well, because I'm getting the same issues when wsitching to <em>IEnumerable</em>.</p>
  
  <p>My impression is that the server somehow times out because the current operation takes too long time. I can either fetch my list entirely without filtration for filtration in the client (which takes a slight forever and fails due to that) or I can apply <em>Where</em> (which requires to use <em>Contains</em> versus another list, which is equivalent to <em>IN</em> in SQL'ish and fails due to that).</p>
  
  <p>I'm kind of at the point when banging my head into a wall slowly emerges as a reasonable approach. I have no control over the DB schema nor ISS (so <a href="http://www.codeproject.com/Tips/126919/Solution-for-The-underlying-provider-failed-on-Ope" rel="nofollow noreferrer">this kind of hints</a> can't even be tested). I have some influence on the configuration of the EF but due to ignorance and outmost respect to the things I don't fully master, I'm very cautious. What can be done here? </p>
  
  <p>The config file looks as follows. </p>
  
  <pre><code>app.config(50,191): 
  &lt;add name="ModelContainer"
       connectionString="metadata=res://*/Model.csdl
         |res://*/Model.ssdl
         |res://*/Model.msl;
         provider=System.Data.SqlClient;
         provider connection string=&amp;quot;
         data source=1.2.3.4;
         initial catalog=DataBaseName;
         user id=NServiceBus;
         password=Abc123();
         MultipleActiveResultSets=True;
         App=EntityFramework&amp;quot;" 
       providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>C# (when I switch the execution order, the failure happens on the second line - <em>beep</em> or <em>boop</em>, whichever comes first does succeed).</p>
  
  <pre><code>List&lt;Beep&gt; beeps = context.Beeps.ToList();
  List&lt;Boop&gt; boops = context.Boops.ToList();
  </code></pre>