sf.
sf.

Reputation: 25480

EF Core and SqlAzureExecutionStrategy

I've tried to have a search for anything related to a SqlAzureExecutionStrategy for EF core and came up empty handed.

Does anyone have any information around the need for setting an execution strategy when using EF Core and SQL Azure?

Upvotes: 20

Views: 8933

Answers (1)

Andriy Svyryd
Andriy Svyryd

Reputation: 2041

In EF Core it's called SqlServerRetryingExecutionStrategy as it is also useful for on-premise SQL Server if you are using memory-optimized tables for example.

It can be enabled in this way:

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder
        .UseSqlServer(
            "<connection string>",
            options => options.EnableRetryOnFailure());
}

See Connection Resiliency for more info.

Upvotes: 31

Related Questions