-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Copy link
Milestone
Description
We are running into an issue while trying to set an infinite timeout for our dbcontext.
During startup we are configuring our context with UseSqlServer und setting CommandTimeout on the builder.
options.UseSqlServer(connectionString, builder => builder.CommandTimeout(0));
This calls WithCommandTimeout internally and throws an exception for values <= 0.
efcore/src/EFCore.Relational/Infrastructure/RelationalOptionsExtension.cs
Lines 163 to 170 in e9b942b
public virtual RelationalOptionsExtension WithCommandTimeout(int? commandTimeout) | |
{ | |
if (commandTimeout is <= 0) | |
{ | |
throw new InvalidOperationException(RelationalStrings.InvalidCommandTimeout(commandTimeout)); | |
} | |
var clone = Clone(); |
The documentation lists 0 as a valid value.
Setting the timeout with context.Database.SetCommandTimeout(0) or context.Database.SetCommandTimeout(Timeout.Infinite) works as expected.
Should be a small change. We could create a PR if you'd like.