Skip to content

Commit a921a43

Browse files
Provide Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore package README (dotnet#57807)
1 parent 0df1def commit a921a43

File tree

1 file changed

+33
-0
lines changed
  • src/Middleware/HealthChecks.EntityFrameworkCore/src

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## About
2+
3+
`Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` provides components for performing health checks using Entity Framework Core (EF Core).
4+
5+
## How to Use
6+
7+
To use `Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore`, follow these steps:
8+
9+
### Installation
10+
11+
```shell
12+
dotnet add package Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore
13+
```
14+
15+
### Configuration
16+
17+
To add a health check for an EF Core `DbContext`, use the `AddDbContextCheck` extension method to configure it with your app's service provider. Here's an example:
18+
19+
```csharp
20+
builder.Services.AddDbContext<SampleDbContext>(options =>
21+
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
22+
23+
builder.Services.AddHealthChecks()
24+
.AddDbContextCheck<SampleDbContext>();
25+
```
26+
27+
## Additional Documentation
28+
29+
For additional documentation and examples, refer to the [official documentation](https://learn.microsoft.com/aspnet/core/host-and-deploy/health-checks#entity-framework-core-dbcontext-probe) on using the Entity Framework Core `DbContext` probe.
30+
31+
## Feedback &amp; Contributing
32+
33+
`Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore` is released as open-source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/aspnetcore).

0 commit comments

Comments
 (0)