question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EFcore TimesOut when executing long time taking queries

See original GitHub issue

Describe what is not working as expected. Ef core when executing stored procedure, that takes more than few millions of records.

times out abruptly. i use EF core as async. the result might be from search of 3 record from a million to few 100. If you are seeing an exception, include the full exceptions details (message and stack trace). execption : ef core timeout.

Exception message:
Stack trace:

Steps to reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

  1. stored procedure which joins tables with more than few millions of records.
  2. select 5 records from the entire joined tables.
  3. return the result set .
  4. EF core is async

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

Console.WriteLine("Hello World!");

Further technical details

EF Core version: (found in project.csproj or packages.config) Database Provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer) Operating system: IDE: (e.g. Visual Studio 2015) visual studio 2015 update 3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:36 (13 by maintainers)

github_iconTop GitHub Comments

21reactions
Wayne-Mathercommented, Aug 22, 2017

I had a similiar issue but resolved it as follows:

public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
            : base(options)
{
      Database.SetCommandTimeout(9000);
}

See if that at least solves the timeout problem for yourself

18reactions
Wayne-Mathercommented, Aug 27, 2017

@kishoretvk we are not denying ef core throws an exception when the timeout occurs. what we are trying to understand is where the problem lies.

the issue will probably be in one or more of the areas below:

  • bad database schema design
  • bad entity design
  • bad sql generation
  • bad execution plan
  • missing indexes
  • non-optimized stored procedure
  • using linked servers

with all this we currently think the problem is not in ef but in the sql server stack somewhere and trying to help you find the problem so a solution can be provided. regardless of what the cause of the problem truly is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework Core 3.1 is throwing a timeout exception ...
I have a paged query that throws an time-out exception when executed by EF Core 3.1. Microsoft.Data.SqlClient.SqlException (0x80131904): ...
Read more >
Query still running in SQL Server Database even though ...
Query still running in SQL Server Database even though CommandTimeout was set to terminate query after a set time in entity framework.
Read more >
Extending the Command Timeout in Entity Framework ...
Sometimes, however, you might also want to include a task that requires longer than the default command timeout value (30 seconds in SQL...
Read more >
query time out from .net code
Your query is taking longer than 30 seconds to run, so the .net app cancels it (that's what a timeout is). Identify the...
Read more >
Query timeouts for one user, works fine for all others, and ...
The application I am responsible for will work fine most of the time, then seemingly randomly one or two users will start experiencing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found