In our web app, as expected, the
It is registered with this extension method (the one that take a
Now every now and then, due to maintenance task in our UAT servers, the Database is offline for a little while.
If that ever happen while someone try to connect to the DB, anyservice that need that DbContext fail with the same exception. Regardless whether the DB is back online or not.
We need to restart the app to fix that.
Now I wonder.. is there a way to fix that? (A way that doesn't involve restarting our app!)
DbContext
for our data is injected with DI.It is registered with this extension method (the one that take a
Func<>
factory method):publicstatic IServiceCollection AddScoped<TService>(this IServiceCollection services, Func<IServiceProvider, TService> implementationFactory) where TService : class;
Now every now and then, due to maintenance task in our UAT servers, the Database is offline for a little while.
If that ever happen while someone try to connect to the DB, anyservice that need that DbContext fail with the same exception. Regardless whether the DB is back online or not.
We need to restart the app to fix that.
Now I wonder.. is there a way to fix that? (A way that doesn't involve restarting our app!)