I have a query that, when executed from my application throws
[SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
I get the same error when stepping through the code in Visual Studio.
But when executing the code in SQL Server Management studio using the same credentials, the query returns instantly (no rows are returned in this case).
The query is generated by Entity framework- I tested in SSMS by extracting the sql from the IQueryable and pasting it in a query window. The timeout error occurs when the code hits "ToList()".
The SQL Server is running in an Azure hosted VM.
For some context, I have seen similar behavior once before, but the last instance was a troublesome (and quite complex) stored procedure. Occasionally, the sp would get in a state where it would only time out from VS or .NET, but would run fine from SSMS. The fix would be to drop and re-create the SP.
This current query is simple by comparison, but I don't know how to "clear it" like I did with the sp, since it's generated on the client.
Does anyone know what could cause a particular query to time out, but only from some clients?
.NET 4.5., EF 6.0.
The query times out after 30 seconds (the default timeout period). I didn't think the actual contents of the query were relevant- the code that runs it has been in place for nearly a year, and has run without a problem until yesterday. It's a relatively simple query that joins 2 tables and has an EXISTS in the where clause on a third.