QueryDoctor.SqlCommenter.EFCore 8.0.0

dotnet add package QueryDoctor.SqlCommenter.EFCore --version 8.0.0
                    
NuGet\Install-Package QueryDoctor.SqlCommenter.EFCore -Version 8.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="QueryDoctor.SqlCommenter.EFCore" Version="8.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QueryDoctor.SqlCommenter.EFCore" Version="8.0.0" />
                    
Directory.Packages.props
<PackageReference Include="QueryDoctor.SqlCommenter.EFCore" />
                    
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 QueryDoctor.SqlCommenter.EFCore --version 8.0.0
                    
#r "nuget: QueryDoctor.SqlCommenter.EFCore, 8.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 QueryDoctor.SqlCommenter.EFCore@8.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=QueryDoctor.SqlCommenter.EFCore&version=8.0.0
                    
Install as a Cake Addin
#tool nuget:?package=QueryDoctor.SqlCommenter.EFCore&version=8.0.0
                    
Install as a Cake Tool

QueryDoctor.SqlCommenter.EFCore

EF Core interceptor that appends SQLCommenter-formatted comments to SQL queries for query attribution and observability.

Installation

dotnet add package QueryDoctor.SqlCommenter.EFCore

Quick Start

// In your DbContext configuration or Program.cs
options.UseSqlServer(connectionString).AddSqlCommenter();

This will automatically append comments to all SQL queries:

SELECT * FROM "Users" WHERE "Id" = @p0 /*action='GetUser',controller='Users',db_driver='efcore',file='Controllers%2FUsersController.cs%3A42%3A1',framework='efcore%3A8.0',method='GET'*/

Tags

Tag Description Example
action Controller action or method name GetUser
controller Controller name (without suffix) Users
db_driver Database driver identifier efcore
file Source file location (path:line:column) Controllers/UsersController.cs:42:1
framework EF Core version efcore:8.0
method HTTP method GET

Configuration

options.UseSqlServer(connectionString).AddSqlCommenter(o =>
{
    o.Enabled = true;                  // Enable/disable (default: true)
    o.EnableStackInspection = true;    // Auto-detect caller info (default: true)
    o.MaxStackDepth = 30;              // Max stack frames to inspect (default: 30)
    o.IncludeFrameworkVersion = true;  // Include EF Core version (default: true)
});

Explicit Context

For precise control, use QueryTaggingContext.SetContext() instead of stack inspection:

using (QueryTaggingContext.SetContext(action: "GetUser", controller: "Users"))
{
    var user = await context.Users.FindAsync(id);
}

Explicit context always takes priority over stack inspection. Caller file path, line number, and member name are automatically captured via [CallerFilePath], [CallerLineNumber], and [CallerMemberName].

Spec Compliance

  • Keys are sorted lexicographically
  • Values are URL-encoded and wrapped in single quotes
  • SQL with existing comments (/* or */) is not modified
  • Errors during tagging never fail the query

License

Apache-2.0

Product 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
8.0.0 97 2/26/2026