DeveloperToolkit.SqlPerformance
1.0.0
dotnet add package DeveloperToolkit.SqlPerformance --version 1.0.0
NuGet\Install-Package DeveloperToolkit.SqlPerformance -Version 1.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="DeveloperToolkit.SqlPerformance" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DeveloperToolkit.SqlPerformance" Version="1.0.0" />
<PackageReference Include="DeveloperToolkit.SqlPerformance" />
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 DeveloperToolkit.SqlPerformance --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DeveloperToolkit.SqlPerformance, 1.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 DeveloperToolkit.SqlPerformance@1.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=DeveloperToolkit.SqlPerformance&version=1.0.0
#tool nuget:?package=DeveloperToolkit.SqlPerformance&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DeveloperToolkit.SqlPerformance
A production-ready .NET 8 NuGet package that automatically monitors SQL performance in ASP.NET Core applications using Entity Framework Core.
Features
- EF Core Interceptor - Automatically captures SQL queries, parameters, execution time, and more
- Slow Query Detection - Configurable threshold with actionable suggestions
- Duplicate Query Detection - Identifies N+1 query problems
- SELECT * Detection - Warns against retrieving all columns
- Missing WHERE Detection - Catches potentially dangerous DML without WHERE clauses
- Large Result Set Detection - Suggests pagination for oversized results
- Index Suggestions - Recommends indexes for slow queries
- Parameter Logging - Logs parameters with sensitive data masking
- SQL Formatter - Pretty-prints SQL for readability
- Built-in Dashboard - Real-time HTML dashboard at
/sql-performance - Export - JSON and CSV export support
Installation
dotnet add package DeveloperToolkit.SqlPerformance
Quick Start
// Program.cs
var builder = WebApplication.CreateBuilder(args);
// Add SQL Performance Monitor (one line!)
builder.Services.AddSqlPerformanceMonitor();
// Configure your DbContext with the interceptor
builder.Services.AddDbContext<AppDbContext>((sp, options) =>
{
options.UseSqlServer(connectionString);
options.AddInterceptors(sp.GetRequiredService<SqlPerformanceInterceptor>());
});
var app = builder.Build();
// Enable middleware and dashboard
app.UseSqlPerformanceMonitor();
app.UseSqlPerformanceDashboard();
app.Run();
Configuration
builder.Services.AddSqlPerformanceMonitor(options =>
{
options.SlowQueryThreshold = 500; // ms (default: 500)
options.EnableDashboard = true; // default: true
options.EnableDuplicateDetection = true; // default: true
options.EnableParameterLogging = true; // default: true
options.EnableSuggestions = true; // default: true
options.EnableFormatting = true; // default: true
options.EnableExport = true; // default: true
options.LargeResultSetThreshold = 1000; // rows (default: 1000)
options.MaxStoredExecutions = 1000; // default: 1000
options.DashboardPath = "/sql-performance"; // default
// Ignore specific tables
options.IgnoredTables.Add("__EFMigrationsHistory");
options.IgnoredTables.Add("AuditLog");
// Ignore specific query patterns
options.IgnoredQueries.Add("INFORMATION_SCHEMA");
// Add custom sensitive parameter names
options.SensitiveParameters.Add("my_secret_field");
});
Dashboard
Navigate to /sql-performance to access the built-in dashboard showing:
- Total Queries
- Slow Queries
- Average Execution Time
- Longest Query
- Duplicate Queries
- Failed Queries
- Detailed execution table with suggestions
API Endpoints
| Endpoint | Description |
|---|---|
GET /sql-performance |
HTML Dashboard |
GET /sql-performance/api/report |
JSON performance report |
GET /sql-performance/api/export/json |
Export report as JSON file |
GET /sql-performance/api/export/csv |
Export report as CSV file |
POST /sql-performance/api/clear |
Clear all collected data |
How It Works
- Interceptor captures every SQL command via EF Core's
DbCommandInterceptor - Analyzers (Strategy Pattern) inspect each execution for issues:
SlowQueryAnalyzer- duration thresholdDuplicateQueryAnalyzer- repeated query detectionSelectStarAnalyzer- SELECT * detectionMissingWhereAnalyzer- dangerous DML detectionLargeResultAnalyzer- oversized result detectionIndexSuggestionAnalyzer- index recommendations
- Collector aggregates results thread-safely
- Logger outputs structured warnings via
ILogger - Dashboard presents real-time metrics
Performance
- Thread-safe using
ConcurrentQueueandInterlockedoperations - Async throughout
- Minimal memory allocations
- No reflection in hot paths
- Low overhead (<2% in typical applications)
- No breaking changes to EF Core behavior
Requirements
- .NET 8.0 or later
- Entity Framework Core 8.0 or later
- ASP.NET Core (for middleware and dashboard)
License
MIT License - see LICENSE for details.
Author
Nilesh More
Contributing
See CONTRIBUTING.md for guidelines.
| 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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
-
net9.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- System.Text.Json (>= 8.0.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 |
|---|---|---|
| 1.0.0 | 146 | 6/25/2026 |