How to set command timeout in aspnetcore/entityframeworkcore

asp.net-core c# entity-framework-core

Question

The place where the command timeout is set is no longer the same as earlier versions.

However, I cannot find anywhere that says how to change this.

What I am doing is uploading very large files which takes longer than the default 30 seconds to save.

Note that I ask about Command Timeout, not Migration Timeout as in another question.

1
33
7/24/2019 6:23:46 AM

Popular Answer

If you're using the DI container to manage the DbContext (i.e. you're adding the DbContext to the service collection), the command timeout can be specified in the options.

In Startup.ConfigureServices:

services.AddDbContext<YourDbContext>(options => options.UseSqlServer(
    this.Configuration.GetConnectionString("YourConnectionString"),
    sqlServerOptions => sqlServerOptions.CommandTimeout(60))
);
68
7/20/2018 7:27:00 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow