1

I'm using EF6 (fully up-to-date) with SQL Server 2012 Express and MVC 5. I've started seeing a new error today--one specific query is timing out. Everything else works properly, just this one query times out. How can I debug this to figure out why this specific query times out? This is a new error, like I said, and only this one query does it (all others run in a minimal amount of time, as expected).

I am using MiniProfiler on the site if there's some way I can use that to check things, but I only have SSMS Express so I can't use Profiler.

1 Answer 1

1

You can create new class inheriting from DbCommandInterceptor (https://msdn.microsoft.com/en-us/library/system.data.entity.infrastructure.interception.dbcommandinterceptor%28v=vs.113%29.aspx).

There, override ReaderExecuted, NonQueryExecuted, ScalarExecuted methods. In each of this methods, there is interceptionContext parameter, which has Exception property with exception occured during execution of given command (if any). Inspect this property, and if it's timeout exception - log DbCommand.CommandText and Parameters.

Then using this information, try to figure out what's wrong using SSMS and raw sql query you got.

Forgot to say - don't forget to do

DbInterception.Add(new YourDbInterceptor());

somewhere on your application startup \ initialization.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.