title: .NET 4.0 Entity framework timeout expired
body: <p>I'm developing an ASP.NET website using MVC3, .NET framework 4.0 and Entity Framework. When I run the application and perform a simple select to a SQL Server 2005 database I get the following error:</p>
  
  <p>"A System.Data.SqlClient.SqlException was thrown: "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."</p>
  
  <p>This is the thing. I tried logging in and performing the same query from management studio and it worked. I developed a small console application using .NET framework 4.0 and entity framework performing the exact same query and it returned the information I needed. I even switched from using Entity framework to ADO.NET classes (SqlConnection and SqlCommand) and when executing the select from the SqlCommand instance I get the exact same error.</p>
  
  <p>When I created the model using entity framework I was able to connect from the wizard to the database and it worked fine. I got all the classes created without any problems.</p>
  
  <p>Please don't tell me the solution is to increase any timeout because the query is really small (20 records tops) and as I said before it worked fine when running it from a console application using the same technology and even the same code I place below.</p>
  
  <p>This is the code giving me the problem:</p>
  
  <pre><code>MLIBEntities dbMLIB = new MLIBEntities();
  
  var searchResults = (from s in dbMLIB.Sets
                       where s.setmap1.StartsWith(accountNumber)
                       select s);
  
  return searchResults.ToList();
  </code></pre>
  
  <p>The exception is thrown when running searchResults.ToList();</p>
  
  <p>This is my connection string being used by the entity classes. I'm sure it uses the connection string since I modified it with syntax errors and they were detected.</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="MLIBEntities" connectionString="metadata=res://*/Models.MlibDBModel.csdl|res://*/Models.MlibDBModel.ssdl|res://*/Models.MlibDBModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;Data Source=HERPADERP;Initial Catalog=MLIB;Integrated Security=True;MultipleActiveResultSets=True;Connect Timeout=200&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>I'm guessing this must be a configuration problem somewhere in the MVC web application or I'm just missing something in the Web.config file. Have any of you had this problem? I know it's really weird.</p>
  
  <p>Thank you for your help. I'm really out of ideas.</p>
  
  <p>One last thing. I ran the SQL profiler and it seems like the query never makes it to the database server. Any ideas of why could this be happening?</p>