title: Entity Framework Issue When running Stored Procedures
body: <p>I have an issue with stored procedures and Entity Framework.</p>
  
  <p>Let me explain what is happening... and what I have tried thus far.</p>
  
  <p>I have a stored procedure, which does not do an awful lot</p>
  
  <pre><code>SELECT 
      COUNT(DISTINCT(EmailAddress)) AcceptedQuotes, 
      CONVERT (DATE,QuoteDate) QuoteDate
  FROM
      Quote Q
  JOIN 
      Person P on Q.PersonPk = P.Pk
  JOIN 
      Product Pr on Q.ProductPk = Pr.Pk
  JOIN 
      Accepted A on Q.Pk = A.QuotePk
  WHERE               
      QuoteDate between @startDate and @endDate
      AND CompanyPk = @companyPk
      AND FirstName != 'Test'
      AND FirstName != 'test'
      AND FirstName != 'EOH'
  </code></pre>
  
  <p>I want to execute this, and it works fine in SSMS and does not even take 1 second.</p>
  
  <p>Now, I import this in to Entity Framework, it times out and I set the command timeout to 120...</p>
  
  <p>Ok so what I have tried thus far and what I have tested.</p>
  
  <p>If I use <code>SqlCommand</code>, <code>SqlDataAdapter</code>, <code>DataTable</code> way, with my own connection string, it executes as expected. When I use Entity Framework connection string in this scenario, it times out.</p>
  
  <p>I altered my stored procedure to include "Recompile" option and also tried the <code>SET ARITHABORT</code> way, no luck, it times out when run through the EF.</p>
  
  <p>Is this a bug in EF?</p>
  
  <p>I have now just about decided to rewrite this using "old school" data access.</p>
  
  <p>Also note that the EF executes fine with other stored procs, from the same database.</p>
  
  <p>Any ideas or help would be greatly appreciated...</p>
  
  <p>PS. I found this article, but no help either :(</p>
  
  <p><a href="http://www.sommarskog.se/query-plan-mysteries.html">http://www.sommarskog.se/query-plan-mysteries.html</a></p>