I am using EF Core 6 vs a SQL Server DB. Sometimes, the execution of a SELECT query takes more than 30 seconds, and goes in timeout.
If I execute the very same SQL generated by EF Core (with the very same parameters, on the same DB, just a few seconds after the timeout), it takes less than a second.
During the overall period, the DB server stays with CPU < 30%.
Running the SQL query on SQL Server Management Studio, I can see that the execution plan is ideal (i.e. it uses the indexes, etc.).
So I am afraid there could be some locking that stops the DB from returning the result of the query.
Is there a way to specify to EF Core e.g. the ISOLATION LEVEL of the query, or even some concurrency / locking strategy?
In my specific scenario, it's ok to have dirty or not completely up-to-date reads, because we have procedures in place to retrieve the clean data in a subsequent round of queries.
Thanks