question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure SQL Database, EF Core EnableRetryOnFailure, and Connection Resiliency

See original GitHub issue

I’m checking in to using Azure SQL Database, and everything seems to be working well so far.

There is an option, however, that I must enable when the db context is configured to retry the connections on failure:

builder.UseSqlServer(connectionString, opt => opt.EnableRetryOnFailure());

When a query is made, it throws the following exception:

InvalidOperationException: The configured execution strategy 'SqlServerRetryingExecutionStrategy' does not support user initiated transactions. Use the execution strategy returned by 'DbContext.Database.CreateExecutionStrategy()' to execute all the operations in the transaction as a retriable unit.

There is more information about it here: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency

Is there anything I can do in order to make this work?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:27 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
orionjensencommented, Mar 8, 2021

Yes. It seems this setting EnableRetryOnFailure is critical in order to host on Azure and this setting is not compatible with ABP.

2reactions
ismcagdascommented, Oct 6, 2021

@jacobmhulse I’m adding this item to 7.1 milestone. We will try to work on it after .NET 6 release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection Resiliency - EF Core
An execution strategy that automatically retries on failures needs to be able to play back each operation in a retry block that fails....
Read more >
Implement resilient Entity Framework Core SQL connections
Learn how to implement resilient Entity Framework Core SQL connections. This technique is especially important when using Azure SQL Database ...
Read more >
SqlServerDbContextOptionsBuil...
EnableRetryOnFailure (Int32). Configures the context to use the default retrying IExecutionStrategy. ; EnableRetryOnFailure(Int32, TimeSpan, ICollection<Int32>).
Read more >
Tips for Improving Entity Framework Core Performance ...
The “EnableRetryOnFailure” option enables resilient SQL connections, and we can configure exactly how it works (max retries, the delay between retries, etc).
Read more >
Implementing resilient Entity Framework Core SQL connections
For Azure SQL DB, Entity Framework Core already provides internal database connection resiliency and retry logic. But you need to enable the Entity...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found