I have an ASP.NET Core Web API with EF Core for database access. In production, some SQL commands are failing with a timeout.
Failed executing DbCommand (30,188ms) [Parameters=[@__country_0='?' (Size = 4000)], CommandType='Text', CommandTimeout='30']
In the error message, the CommandTimeout is 30 seconds. Thus it fails after 30 seconds.
But both, the connection string and the dbContext in the code set the timeout to 600s.
Connection string:
Server=SQLServer;Initial Catalog=Database1;Persist Security Info=False;User ID=user1;Password=1234;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=600;
Set the command timeout in the constructor of API controller:
myDbContext.Database.SetCommandTimeout(600);
Why is this ignored and where do the 30 seconds come from?