As part of a new feature, some code that calls the following method was added
try
{
using (var context = new TRContext())
{
var query = from option in context.Option
where option.package == package && option.type== type
select option;
return query.DefaultIfEmpty(null).First();
}
}
catch (Exception ex)
{
Logger.Error($"Failed to get Option by package='{package}' and type='{type}'", ex);
return null;
}
This is called before as part of other functionality(and works fine), then when fetching it again, I get this error:
System.Data.Entity.Core.EntityException: The underlying provider failed on Open.
System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding
I've tried
- How to use SqlAzureExecutionStrategy and "Nolock"
- https://www.c-sharpcorner.com/UploadFile/ff2f08/prevent-dead-lock-in-entity-framework/
or having context.Databae.Connection.Open()
but get other errors.
What could have led to this ? How could I fix it?