aspnetboilerplate: Azure SQL Database, EF Core EnableRetryOnFailure, and Connection Resiliency

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?

About this issue

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

Most upvoted comments

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

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

Unfortunately, we couldn’t make any progress on this. We are planning to work on this in the next milestone 7.3. Sorry for the delay.

ABP Team: It has been over 2 years since this was opened, any news for us? You guys have built an amazing framework here, shame to have it fall short on such an important piece. Please update us lowly developers. Thank you!

Hello. Just popping in here. This would be a great feature since the EnableRetryOnFailure option is basically required for Azure SQL PaaS.

What all would be involved in creating another IEfTransactionStrategy implementation to mimic the retry functionality?

Edit: FWIW, I’m using ngpql, and this issue is related: https://github.com/npgsql/npgsql/issues/1495

As the error states SqlServerRetryingExecutionStrategy does not work if we use transactions in a regular manner. And ABP does that.

ABP’s transaction strategy is replaceable. It’s defined by the IEfTransactionStrategy interface. There are two built-in implementations:

Maybe creating a 3rd one solves it. We would be happy if anyone contributes it 😃