Database Connection Resiliency

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 3 años
Hi

I am using nopcommerce 4.2 and local database and recently having many  Database Connection Resiliency exception as follow:

"An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseSqlServer' call.."

where this exception occurred in different cases including order placing, updating product, .. etc

I read this is EF core issue and one of the suggestion to add the following code in Startup.cs class in ConfigureServices method:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<PicnicContext>(
        options => options.UseSqlServer(
            "<connection string>",
            providerOptions => providerOptions.EnableRetryOnFailure()));
}

source: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency

BUT, I really don't know which context to use instead of <PicnicContext> or if there is any other better solution.

Thanks
Hace 3 años
Try NopObjectContext.
But you may want to modify code here rather than in startup:
\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ServiceCollectionExtensions.cs


(P.S.  This is not really a 'bug'.  If you are having transient SQL server access problems, then you should try to find out the root cause.)
Hace 3 años
Thanks for response

but when I implemented this code it deleted my logged in account from the database. I don't know if the code is the reason or something.

Anyway, do you suggest alternative solution for this issue?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.