title: EF: The underlying provider failed on Open
body: <p>In production I have started getting this error all across my app:</p>
  
  <pre><code>The underlying provider failed on Open
  </code></pre>
  
  <p>As far as I could tell, I'm not getting this error when testing the app locally (at least I could not get it no matter what I did). I'm using Azure SQL server and here is my connection string: </p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="DefaultConnection" connectionString="Data Source=myserver.windows.net,1433;Database=mydb;User ID=username;Password=password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>Here is one of methods where I'm getting error:</p>
  
  <pre><code>public IEnumerable&lt;Country&gt; GetCountries()
  {
          List&lt;Country&gt; countries;
          using (var databaseContext = new Database())
          {
              countries = databaseContext.Countries.OrderBy(c =&gt; c.Name).ToList();
          }
  
          return countries;
  }
  </code></pre>
  
  <p>Also I want to stress out that error is not happening all the time, it happens kinda randomly. This started to happen today, I have not changed this code, nor connection sting, nor database settings, but (!) I have refactored some methods from synchronous to asynchronous - I don't know this is somehow connected to this particular problem.  </p>
  
  <p>Also as far as I could tell this is only happening in ASP.net Web API project, but not in ASP:net MVC project (they share same service layer and call same methods from service)</p>
  
  <p>And finally here is Pastebin link to whole stack trace (I won't paste it here because it is too big): <a href="http://pastebin.com/qwb1w8q9" rel="nofollow">link</a></p>