Closed Inlustris closed 5 years ago
Hi @Inlustris
You're right, the HealthChecks.EntityFrameworkCore
implementation expects a DbContext
instance itself rather than a factory of a DbContext
(Func<DbContext>
) that's why you have that issue.
So, as I see this scenario, you could handle that using a custom healthcheck or even using the built-in healthcheck provided by Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore package.
I made a simple example in order to show you both approaches, I think both are correct, so you can create your custom healthcheck which receives a DbContext
factory or you can use the built-in one, injecting a DbContext
as an instance just for the health check purpose. At the end of the day, that instance only will be injected when the health check is executed and it's only for reading purposes, so you shouldn't have concurrency issues.
So, let me know if that helps.
PD: The idea to implement a healthcheck using DbContextFactory
out of the box is great, let's see if more people request it, then we can package it!
Hello vany0114,
We use the dbcontextfactory and would like to start using the EF 2.2 health checks. After starting with the health checks i encountered a problem. The healthcheck delivered in AspNet makes use of DbContext. And not the DbContextFactory we use.
Is it possible to create or implement the healthcheck of 2.2 in this package?
King regards Inlustris,