I am trying to implement a DbContext health check. The Sql health check doesn't work for me as I could be using any of a number of database providers such as PostgreSQL.
However, the check function needs a scoped instance of the DbContext to test, and this is not available during the Startup.ConfigureServices method.
If the HealthCheckServices passed in the IServiceScope, then the check method could get any services it required using IServiceScope.ServiceProvider.
Found out the way to do it. Use the AddCheck<DbConetextChecker> method where the DbConetextChecker constructor has an IServiceScope parameter. The type gets resolve at execution time.
I am trying to implement a DbContext health check. The Sql health check doesn't work for me as I could be using any of a number of database providers such as PostgreSQL.
However, the check function needs a scoped instance of the DbContext to test, and this is not available during the Startup.ConfigureServices method.
If the HealthCheckServices passed in the IServiceScope, then the check method could get any services it required using IServiceScope.ServiceProvider.