AspNetCore.HealthChecks.MongoDb 9.0.0

Prefix Reserved
dotnet add package AspNetCore.HealthChecks.MongoDb --version 9.0.0
                    
NuGet\Install-Package AspNetCore.HealthChecks.MongoDb -Version 9.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AspNetCore.HealthChecks.MongoDb" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="AspNetCore.HealthChecks.MongoDb" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AspNetCore.HealthChecks.MongoDb --version 9.0.0
                    
#r "nuget: AspNetCore.HealthChecks.MongoDb, 9.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AspNetCore.HealthChecks.MongoDb@9.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AspNetCore.HealthChecks.MongoDb&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=AspNetCore.HealthChecks.MongoDb&version=9.0.0
                    
Install as a Cake Tool

MongoDB Health Check

This health check verifies the ability to communicate with MongoDB. It uses the provided MongoClient to list database names or ping configured database.

Defaults

By default, the MongoClient instance is resolved from service provider.

void Configure(IHealthChecksBuilder builder)
{
    builder.Services
        .AddSingleton(sp => new MongoClient("mongodb://localhost:27017"))
        .AddHealthChecks()
        .AddMongoDb();
}

Customization

You can additionally add the following parameters:

  • clientFactory: A factory method to provide MongoClient instance.
  • databaseNameFactory: A factory method to provide database name.
  • name: The health check name. The default is mongodb.
  • failureStatus: The HealthStatus that should be reported when the health check fails. Default is HealthStatus.Unhealthy.
  • tags: A list of tags that can be used to filter sets of health checks.
  • timeout: A System.TimeSpan representing the timeout of the check.
void Configure(IHealthChecksBuilder builder)
{
    builder.Services
        .AddSingleton(sp => new MongoClient("mongodb://localhost:27017"))
        .AddHealthChecks()
        .AddMongoDb(databaseNameFactory: sp => "theName");
}

Breaking changes

MongoDbHealthCheck was letting the users specify how MongoClient should be created (from raw connection string or from MongoUrl or from MongoClientSettings), at a cost of maintaining an internal, static client instances cache. Now the type does not create client instances nor maintain an internal cache and it's the caller responsibility to provide the instance of MongoClient (please see #2048 for more details). Since MongoDB recommends treating clients as singletons and client instances can be expensive to create, it's recommended to register a singleton factory method for MongoClient. So the client is created only when needed and once per whole application lifetime.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (70)

Showing the top 5 NuGet packages that depend on AspNetCore.HealthChecks.MongoDb:

Package Downloads
Reo.Core.NoSql

Package Description

Reo.Core.AutoHistory

Package Description

Reo.Core.Testing

Package Description

Reo.Core.Email

Package Description

Reo.Core.IntegrationTesting

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on AspNetCore.HealthChecks.MongoDb:

Repository Stars
dotnet/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
dotnetcore/osharp
OSharp是一个基于.Net6.0的快速开发框架,框架对 AspNetCore 的配置、依赖注入、日志、缓存、实体框架、Mvc(WebApi)、身份认证、功能权限、数据权限等模块进行更高一级的自动化封装,并规范了一套业务实现的代码结构与操作流程,使 .Net 框架更易于应用到实际项目开发中。
Version Downloads Last Updated
9.0.0 3,119,758 12/19/2024
8.1.0 2,329,249 8/28/2024
8.0.1 2,468,584 4/2/2024
8.0.0 1,315,506 12/15/2023
7.0.0 1,363,245 7/30/2023
7.0.0-rc2.6 44,496 3/13/2023
7.0.0-rc2.5 42,193 1/14/2023
7.0.0-rc2.4 953 12/27/2022
7.0.0-rc2.3 2,765 12/27/2022
6.0.2 8,393,830 2/28/2022
6.0.1 1,183,897 12/29/2021
6.0.1-rc2.2 25,437 11/10/2021
6.0.1-rc1.1 829 11/5/2021
6.0.0 59,829 12/29/2021
5.0.1 2,675,480 1/5/2021
5.0.0 62,850 12/29/2020
5.0.0-preview1 2,729 11/22/2020
3.1.3 1,655,398 10/22/2020
3.1.2 920,241 6/26/2020
3.1.1 466,563 4/17/2020
Loading failed