Neon.EntityFrameworkCore.Analyzers
4.0.21
dotnet add package Neon.EntityFrameworkCore.Analyzers --version 4.0.21
NuGet\Install-Package Neon.EntityFrameworkCore.Analyzers -Version 4.0.21
<PackageReference Include="Neon.EntityFrameworkCore.Analyzers" Version="4.0.21" />
<PackageVersion Include="Neon.EntityFrameworkCore.Analyzers" Version="4.0.21" />
<PackageReference Include="Neon.EntityFrameworkCore.Analyzers" />
paket add Neon.EntityFrameworkCore.Analyzers --version 4.0.21
#r "nuget: Neon.EntityFrameworkCore.Analyzers, 4.0.21"
#:package Neon.EntityFrameworkCore.Analyzers@4.0.21
#addin nuget:?package=Neon.EntityFrameworkCore.Analyzers&version=4.0.21
#tool nuget:?package=Neon.EntityFrameworkCore.Analyzers&version=4.0.21
Neon.EntityFrameworkCore.Analyzers
Roslyn analyzers for Entity Framework Core queries.
NEONEFC0001 — EF Core query should be tagged with its call site
EF Core's TagWithCallSite()
prefixes the generated SQL with the source file and line the query was written on:
-- file: C:\Work\MyService\UserRepository.cs:42
SELECT u."Id", u."Name" FROM "Users" AS u WHERE u."Active"
That comment is what turns a slow query sitting in a database log into a line of code you can open. This rule reports EF Core queries that are executed without it.
// NEONEFC0001
var users = await context.Users
.Where(user => user.Active)
.ToListAsync(cancellationToken);
// OK
var users = await context.Users
.TagWithCallSite()
.Where(user => user.Active)
.ToListAsync(cancellationToken);
The tag may appear anywhere in the chain, including on a query built up across several methods, so factoring a query out into a helper that tags it satisfies the rule at every call site that composes on top of it.
Where the rule stays quiet
It only fires where the tag can actually be applied and would actually reach the database:
- The compilation must reference an EF Core that offers
TagWithCallSite()(EF Core 6.0 or later). - The query must trace back to a
DbSet<T>orDbContext.Set<T>(). A query the analyzer cannot follow to a root — one handed in as anIQueryable<T>parameter, say — is left alone rather than guessed at. - Queries composed inside an expression tree are skipped. They are translated as part of the enclosing query, which is where the tag belongs.
- LINQ over in-memory sequences is not EF Core's business and is never reported.
Configuration
Add this to .editorconfig to accept a TagWith() call in place of TagWithCallSite():
neon_efcore_tag_with_call_site_allow_tag_with = true
The rule's severity is set the usual way:
dotnet_diagnostic.NEONEFC0001.severity = suggestion
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
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 |
|---|---|---|
| 4.0.21 | 98 | 9/11/2026 |
| 4.0.21-preview.0 | 70 | 9/9/2026 |