2 Incorporated comment; formatting; minor edits while I was there
source | link

Just to discount the difference with the MVC app - Have you checked the query it is executing using SQL Profiler?

I had a similar problem recently, and it turns out the query executed through my MVC app (using Entity Framework 6) was executing the sqlSQL statement through sp_executesqlsp_executesql, which was causing sql serverSQL Server to use a different execution plan compared to running pure sqlSQL in Management Studio.

We changed it to use a stored procedure rather than LINQ.

Just to discount the difference with the MVC app - Have you checked the query it is executing using SQL Profiler?

I had a similar problem recently, and it turns out the query executed through my MVC app (using Entity Framework 6) was executing the sql statement through sp_executesql, which was causing sql server to use a different execution plan compared to running pure sql in Management Studio

Just to discount the difference with the MVC app - Have you checked the query it is executing using SQL Profiler?

I had a similar problem recently, and it turns out the query executed through my MVC app (using Entity Framework 6) was executing the SQL statement through sp_executesql, which was causing SQL Server to use a different execution plan compared to running pure SQL in Management Studio.

We changed it to use a stored procedure rather than LINQ.

1
source | link

Just to discount the difference with the MVC app - Have you checked the query it is executing using SQL Profiler?

I had a similar problem recently, and it turns out the query executed through my MVC app (using Entity Framework 6) was executing the sql statement through sp_executesql, which was causing sql server to use a different execution plan compared to running pure sql in Management Studio