Share via


SqlEngineDbContextOptionsBuilder.EnableRetryOnFailure Method

Definition

Overloads

EnableRetryOnFailure()

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure(ICollection<Int32>)

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure(Int32)

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure(Int32, TimeSpan, IEnumerable<Int32>)

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure()

Source:
SqlEngineDbContextOptionsBuilder.cs

Configures the context to use the default retrying IExecutionStrategy.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder EnableRetryOnFailure ();
abstract member EnableRetryOnFailure : unit -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
override this.EnableRetryOnFailure : unit -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
Public Overridable Function EnableRetryOnFailure () As SqlEngineDbContextOptionsBuilder

Returns

Remarks

This strategy is specifically tailored to SQL Server, Azure SQL, Azure Synapse. 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.

Applies to

EnableRetryOnFailure(ICollection<Int32>)

Source:
SqlEngineDbContextOptionsBuilder.cs

Configures the context to use the default retrying IExecutionStrategy.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder EnableRetryOnFailure (System.Collections.Generic.ICollection<int> errorNumbersToAdd);
abstract member EnableRetryOnFailure : System.Collections.Generic.ICollection<int> -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
override this.EnableRetryOnFailure : System.Collections.Generic.ICollection<int> -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
Public Overridable Function EnableRetryOnFailure (errorNumbersToAdd As ICollection(Of Integer)) As SqlEngineDbContextOptionsBuilder

Parameters

errorNumbersToAdd
ICollection<Int32>

Additional SQL error numbers that should be considered transient.

Returns

Remarks

This strategy is specifically tailored to SQL Server, Azure SQL, Azure Synapse. 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.

Applies to

EnableRetryOnFailure(Int32)

Source:
SqlEngineDbContextOptionsBuilder.cs

Configures the context to use the default retrying IExecutionStrategy.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder EnableRetryOnFailure (int maxRetryCount);
abstract member EnableRetryOnFailure : int -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
override this.EnableRetryOnFailure : int -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
Public Overridable Function EnableRetryOnFailure (maxRetryCount As Integer) As SqlEngineDbContextOptionsBuilder

Parameters

maxRetryCount
Int32

Returns

Remarks

This strategy is specifically tailored to SQL Server, Azure SQL, Azure Synapse. It is pre-configured with error numbers for transient errors that can be retried.

A default value 30 seconds for the maximum default delay is used.

See Connection resiliency and database retries for more information and examples.

Applies to

EnableRetryOnFailure(Int32, TimeSpan, IEnumerable<Int32>)

Source:
SqlEngineDbContextOptionsBuilder.cs

Configures the context to use the default retrying IExecutionStrategy.

public virtual Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder EnableRetryOnFailure (int maxRetryCount, TimeSpan maxRetryDelay, System.Collections.Generic.IEnumerable<int>? errorNumbersToAdd);
abstract member EnableRetryOnFailure : int * TimeSpan * seq<int> -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
override this.EnableRetryOnFailure : int * TimeSpan * seq<int> -> Microsoft.EntityFrameworkCore.Infrastructure.SqlEngineDbContextOptionsBuilder
Public Overridable Function EnableRetryOnFailure (maxRetryCount As Integer, maxRetryDelay As TimeSpan, errorNumbersToAdd As IEnumerable(Of Integer)) As SqlEngineDbContextOptionsBuilder

Parameters

maxRetryCount
Int32

The maximum number of retry attempts.

maxRetryDelay
TimeSpan

The maximum delay between retries.

errorNumbersToAdd
IEnumerable<Int32>

Additional SQL error numbers that should be considered transient.

Returns

Remarks

This strategy is specifically tailored to SQL Server, Azure SQL, Azure Synapse. It is pre-configured with error numbers for transient errors that can be retried, but additional error numbers can also be supplied.

See Connection resiliency and database retries for more information and examples.

Applies to