如何使用AspNetCore.HealthChecks.SqlServer检查多个数据库?

How to check multiple database using AspNetCore.HealthChecks.SqlServer?

目前我已经使用这些代码检查了一个数据库:

services.AddHealthChecks()
               .AddSqlServer(
                 connectionString: Configuration.GetConnectionString("DefaultConnection"),
                 healthQuery: "SELECT 1;",
                 name: "sql",
                 failureStatus: HealthStatus.Degraded,
                 tags: new string[] { "db", "sql", "sqlserver" }
               );

但是如何查询多个数据库呢?我正在使用 .NET Core 3.1 和 AspNetCore.HealthChecks.SqlServer Version=3.1.1.

添加另一个 AddSqlServer 方法但使用不同的 namename 必须是唯一的。

services.AddHealthChecks()
    .AddSqlServer(
        connectionString: Configuration.GetConnectionString("DefaultConnection"),
        healthQuery: "SELECT 1;",
        name: "sql",
        failureStatus: HealthStatus.Degraded,
        tags: new string[] { "db", "sql", "sqlserver" })
    .AddSqlServer(
        connectionString: Configuration.GetConnectionString("AnotherConnection"),
        healthQuery: "SELECT 1;",
        name: "sql2",
        failureStatus: HealthStatus.Degraded,
        tags: new string[] { "db", "sql", "sqlserver" }
           );