1

I register DbContext using Dependency Injection, where I use connection string and CommandTimeout(600) option.

But when I use the sqlServerOption having command timeout set, it is not working. In resolved context I always receive timeout used in connection string (or default if not specified in connection string). I don't want to set timeout via connection string for some reasons. What's wrong there please? I found question How to set CommandTimeout for DbContext?, but solved differently.

services.AddDbContext<MyDbContext>(
    options => options.UseSqlServer(
        "someConnectionString",
        sqlServerOptions => sqlServerOptions.CommandTimeout(600))); //600s
Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
procma
  • 1,174
  • 3
  • 14
  • 24

1 Answers1

0

did you pass options parameters to DbContext base?

 public partial class MyDbContext : DbContext
    {       
        public MyDbContext(DbContextOptions<MyDBContext> options) : base(options)
        {
        }

        ....
    }
levent
  • 3,464
  • 1
  • 12
  • 22