Spyglass.AspNetCore.EntityFrameworkCore 0.2.1

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

Spyglass.AspNetCore.EntityFrameworkCore

EF Core integration for the Spyglass observability dashboard. Captures slow queries and failed queries via a DbCommandInterceptor and streams them live to a dedicated Queries tab.

Installation

dotnet add package Spyglass.AspNetCore.EntityFrameworkCore

Requires Spyglass.AspNetCore.

Setup

Call .AddEntityFrameworkCore() on the Spyglass builder, then add the interceptor to each DbContext:

builder.Services.AddSpyglass()
    .AddEntityFrameworkCore();

builder.Services.AddDbContext<AppDbContext>((sp, options) =>
{
    options.UseNpgsql(connectionString);
    options.AddSpyglassInterceptor(sp);
});

AddSpyglassInterceptor is a convenience extension on DbContextOptionsBuilder. You can also register the interceptor directly:

options.AddInterceptors(sp.GetRequiredService<SpyglassQueryInterceptor>());

Configuration

Pass a configuration delegate to adjust capture behaviour:

builder.Services.AddSpyglass()
    .AddEntityFrameworkCore(options =>
    {
        options.SlowQueryThresholdMs = 250; // default: 100
        options.MaxCommandTextLength = 5_000; // default: 10 000
    });
Option Default Description
SlowQueryThresholdMs 100 Queries at or above this threshold (ms) are captured. Set to 0 to capture all queries.
MaxCommandTextLength 10000 Maximum characters captured from CommandText. Longer SQL is truncated to avoid memory bloat.

What it shows

The Queries tab streams captured entries live and retains up to 500 in memory. Each entry shows:

  • Time — when the command completed
  • DbContext — the DbContext subclass that issued the command
  • Elapsed — execution time; colour-coded neutral / amber (1–5× threshold) / red (5×+)
  • Status — OK or Error
  • Query — a truncated preview of the SQL

Click any row to expand a detail panel with the full SQL and, for errors, the exception message.

The page includes an Errors only toggle, a SQL search filter, sortable columns, and auto-scroll.

All queries are captured regardless of the EF Core provider — the interceptor hooks at the DbCommand level.

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
0.2.1 139 6/7/2026
0.2.0 105 6/7/2026
0.1.0 117 6/4/2026