Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Azure by (45.3k points)

Could anyone guide me on how to implement a retry policy with EF to SQL Azure, please?

1 Answer

0 votes
by (16.8k points)

Add the binary, or the project in the link above to your solution, and add the reference to your project.

Instantiate a retry policy with suitable parameters:

    var retryPolicy = new RetryPolicy<SqlAzureTransientErrorDetectionStrategy>(




    ) { FastFirstRetry = true };

Use your retry policy object for any atomic work on the context.

    using(var context = new ... )


        ...//Maybe you do something to the database...

        retryPolicy.ExecuteAction(() => context.SaveChanges());

Browse Categories