How to set command timeout in aspnetcore/entityframeworkcore

后端 未结 3 1712
长情又很酷
长情又很酷 2021-02-06 21:28

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 doi

3条回答
  •  故里飘歌
    2021-02-06 22:03

    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(options => options.UseSqlServer(
        this.Configuration.GetConnectionString("YourConnectionString"),
        sqlServerOptions => sqlServerOptions.CommandTimeout(60))
    );
    

提交回复
热议问题