Veggerby.Ignition.SqlServer
0.5.0
See the version list below for details.
dotnet add package Veggerby.Ignition.SqlServer --version 0.5.0
NuGet\Install-Package Veggerby.Ignition.SqlServer -Version 0.5.0
<PackageReference Include="Veggerby.Ignition.SqlServer" Version="0.5.0" />
<PackageVersion Include="Veggerby.Ignition.SqlServer" Version="0.5.0" />
<PackageReference Include="Veggerby.Ignition.SqlServer" />
paket add Veggerby.Ignition.SqlServer --version 0.5.0
#r "nuget: Veggerby.Ignition.SqlServer, 0.5.0"
#:package Veggerby.Ignition.SqlServer@0.5.0
#addin nuget:?package=Veggerby.Ignition.SqlServer&version=0.5.0
#tool nuget:?package=Veggerby.Ignition.SqlServer&version=0.5.0
Veggerby.Ignition.SqlServer
SQL Server readiness signals for Veggerby.Ignition - verify database connections and schema during application startup.
Installation
dotnet add package Veggerby.Ignition.SqlServer
dotnet add package Microsoft.Data.SqlClient
Usage
Modern Pattern: Connection Factory (Recommended)
The recommended approach uses a connection factory registered in DI for better connection management:
// Register connection factory in DI container
builder.Services.AddSingleton<Func<SqlConnection>>(() =>
new SqlConnection("Server=localhost;Database=MyDb;Trusted_Connection=True;"));
// Add SQL Server readiness signal (automatically resolves factory from DI)
builder.Services.AddIgnition();
builder.Services.AddSqlServerReadiness();
var app = builder.Build();
await app.Services.GetRequiredService<IIgnitionCoordinator>().WaitAllAsync();
Why Connection Factory?
- Cleaner DI integration: No connection string duplication across services
- Centralized configuration: Single factory registration shared by all consumers
- Testability: Easy to mock or replace for testing
- Connection pooling: SQL Server connection pooling managed by ADO.NET
Legacy Pattern: Connection String
For simpler scenarios or when a connection factory isn't registered in DI:
builder.Services.AddIgnition();
builder.Services.AddSqlServerReadiness(
"Server=localhost;Database=MyDb;Trusted_Connection=True;");
var app = builder.Build();
await app.Services.GetRequiredService<IIgnitionCoordinator>().WaitAllAsync();
With Validation Query
builder.Services.AddSingleton<Func<SqlConnection>>(() => new SqlConnection(connectionString));
builder.Services.AddSqlServerReadiness(options =>
{
options.ValidationQuery = "SELECT 1";
options.Timeout = TimeSpan.FromSeconds(5);
});
Advanced Schema Validation
builder.Services.AddSingleton<Func<SqlConnection>>(() => new SqlConnection(connectionString));
builder.Services.AddSqlServerReadiness(options =>
{
// Verify specific table exists
options.ValidationQuery = "SELECT TOP 1 1 FROM Users";
options.Timeout = TimeSpan.FromSeconds(10);
});
Features
- Connection Verification: Validates database connectivity
- Optional Query Validation: Execute custom queries to verify schema readiness
- Activity Tracing: Tags for server, database, and validation queries
- Structured Logging: Information, Debug, and Error level diagnostics
- Idempotent Execution: Cached results prevent redundant connection attempts
- Thread-Safe: Concurrent readiness checks execute once
Configuration Options
| Property | Type | Description | Default |
|---|---|---|---|
Timeout |
TimeSpan? |
Per-signal timeout override | null (uses global timeout) |
ValidationQuery |
string? |
SQL query to execute after connection | null (connection only) |
Logging
The signal emits structured logs at different levels:
- Information: Connection attempts and successful completions
- Debug: Connection established, validation query execution
- Error: Connection failures, query execution failures
Activity Tracing
When tracing is enabled, the signal adds these tags:
sqlserver.server: Data source from connection stringsqlserver.database: Initial catalog from connection stringsqlserver.validation_query: Validation query if configured
Examples
Health Check Integration
builder.Services.AddIgnition();
builder.Services.AddSqlServerReadiness(connectionString);
builder.Services
.AddHealthChecks()
.AddCheck<IgnitionHealthCheck>("ignition-readiness");
Multiple Databases
// Primary database
builder.Services.AddSqlServerReadiness(
primaryConnectionString,
options =>
{
options.ValidationQuery = "SELECT 1";
options.Timeout = TimeSpan.FromSeconds(5);
});
// Reporting database
builder.Services.AddSqlServerReadiness(
reportingConnectionString,
options =>
{
options.ValidationQuery = "SELECT 1";
options.Timeout = TimeSpan.FromSeconds(10);
});
Note: Currently, multiple SQL Server signals will share the same name ("sqlserver-readiness"). For distinct signals, implement custom IIgnitionSignal with unique names.
Error Handling
Connection failures and query execution errors are logged and propagated:
try
{
await coordinator.WaitAllAsync();
}
catch (AggregateException ex)
{
foreach (var inner in ex.InnerExceptions)
{
if (inner is SqlException sqlEx)
{
// Handle SQL Server-specific errors
Console.WriteLine($"SQL Error {sqlEx.Number}: {sqlEx.Message}");
}
}
}
Performance
- Minimal allocations per signal invocation
- Connection pooling handled by
Microsoft.Data.SqlClient - Async throughout (no blocking I/O)
- Idempotent execution (connection attempted once)
License
MIT License. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Microsoft.Data.SqlClient (>= 6.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Veggerby.Ignition (>= 0.5.0)
-
net8.0
- Microsoft.Data.SqlClient (>= 6.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Veggerby.Ignition (>= 0.5.0)
-
net9.0
- Microsoft.Data.SqlClient (>= 6.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Veggerby.Ignition (>= 0.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.1-prerelease0022 | 76 | 1/26/2026 |
| 0.5.1-prerelease0021 | 75 | 1/22/2026 |
| 0.5.1-prerelease0020 | 76 | 1/22/2026 |
| 0.5.1-prerelease0019 | 81 | 1/21/2026 |
| 0.5.1-prerelease0018 | 74 | 1/21/2026 |
| 0.5.1-prerelease0017 | 74 | 1/20/2026 |
| 0.5.1-prerelease0016 | 73 | 1/20/2026 |
| 0.5.1-prerelease0014 | 76 | 1/20/2026 |
| 0.5.1-prerelease0013 | 78 | 1/20/2026 |
| 0.5.1-prerelease0011 | 77 | 1/19/2026 |
| 0.5.1-prerelease0009 | 79 | 1/19/2026 |
| 0.5.1-prerelease0008 | 81 | 1/17/2026 |
| 0.5.1-prerelease0007 | 83 | 1/16/2026 |
| 0.5.1-prerelease0006 | 81 | 1/16/2026 |
| 0.5.1-prerelease0004 | 80 | 1/16/2026 |
| 0.5.1-prerelease0003 | 78 | 1/15/2026 |
| 0.5.1-prerelease0002 | 79 | 1/15/2026 |
| 0.5.1-prerelease0001 | 80 | 1/15/2026 |
| 0.5.0 | 81 | 1/14/2026 |
| 0.4.2-prerelease0011 | 84 | 1/14/2026 |
| 0.4.2-prerelease0010 | 81 | 1/14/2026 |
| 0.4.2-prerelease0009 | 79 | 1/14/2026 |
| 0.4.2-prerelease0008 | 82 | 1/14/2026 |
| 0.4.2-prerelease0007 | 85 | 1/12/2026 |
| 0.4.2-prerelease0006 | 89 | 1/9/2026 |
| 0.4.2-prerelease0005 | 88 | 1/9/2026 |
| 0.4.2-prerelease0002 | 89 | 1/9/2026 |