title: Query is very slow in ASP.net and Profiler, but fast in SQL Management Studio 2014
body: <p>I have a MS SQL query that takes about 40 seconds to run in ASP.NET (EF Linq).
  I have captured it in Profiler and it shows a duration of about 40 seconds:</p>
  
  <p><a href="https://i.stack.imgur.com/sl3ct.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sl3ct.png" alt="enter image description here"></a></p>
  
  <p>However, when I copy/paste this in <strong>SQL Management Studio</strong> it runs in 00:00:00 seconds. It's a simple <code>select</code> on a single table (no Joins, Views, Stored Procedure) and it returns about 10.000 rows.</p>
  
  <p>Execution plan:</p>
  
  <p><a href="https://i.stack.imgur.com/P0P8q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P0P8q.png" alt="enter image description here"></a></p>
  
  <p>I read <a href="https://stackoverflow.com/questions/10175422/sql-runs-fast-in-ssms-slow-in-asp-net">this question on StackOverflow</a> witch points to <a href="http://www.sommarskog.se/query-plan-mysteries.html" rel="nofollow noreferrer">this blog</a> and placed</p>
  
  <blockquote>
    <p>SET ARITHABORT OFF</p>
  </blockquote>
  
  <p>above the query in Management Studio but that doesn't make it slow so I don't think that is the issue. </p>
  
  <p>One strange thing is that we migrated the application to a faster server with Windows 2012 / SQL 2014 Web Edition and since that time queries seems to run slower. The same query did run a lot faster on our old Windows 2008R2 Server with SQL Express 2008R2.</p>