diff --git a/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs b/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs index 29d32e54f16..521960728a1 100644 --- a/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs +++ b/src/EFCore.SqlServer/Infrastructure/SqlServerDbContextOptionsBuilder.cs @@ -62,6 +62,26 @@ public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure() public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure(int maxRetryCount) => ExecutionStrategy(c => new SqlServerRetryingExecutionStrategy(c, maxRetryCount)); + /// + /// Configures the context to use the default retrying . + /// + /// + /// + /// This strategy is specifically tailored to SQL Server (including SQL Azure). It is pre-configured with + /// error numbers for transient errors that can be retried. + /// + /// + /// Default values of 6 for the maximum retry count and 30 seconds for the maximum default delay are used. + /// + /// + /// See Connection resiliency and database retries + /// for more information and examples. + /// + /// + /// Additional SQL error numbers that should be considered transient. + public virtual SqlServerDbContextOptionsBuilder EnableRetryOnFailure(ICollection errorNumbersToAdd) + => ExecutionStrategy(c => new SqlServerRetryingExecutionStrategy(c, errorNumbersToAdd)); + /// /// Configures the context to use the default retrying . /// diff --git a/src/EFCore.SqlServer/SqlServerRetryingExecutionStrategy.cs b/src/EFCore.SqlServer/SqlServerRetryingExecutionStrategy.cs index 98c92750bdb..cca28b4a2eb 100644 --- a/src/EFCore.SqlServer/SqlServerRetryingExecutionStrategy.cs +++ b/src/EFCore.SqlServer/SqlServerRetryingExecutionStrategy.cs @@ -86,6 +86,21 @@ public SqlServerRetryingExecutionStrategy( { } + /// + /// Creates a new instance of . + /// + /// + /// Default values of 6 for the maximum retry count and 30 seconds for the maximum default delay are used. + /// + /// Parameter object containing service dependencies. + /// Additional SQL error numbers that should be considered transient. + public SqlServerRetryingExecutionStrategy( + ExecutionStrategyDependencies dependencies, + ICollection errorNumbersToAdd) + : this(dependencies, DefaultMaxRetryCount, DefaultMaxDelay, errorNumbersToAdd) + { + } + /// /// Creates a new instance of . ///