EFDoctor.Analyzers 0.6.0

dotnet add package EFDoctor.Analyzers --version 0.6.0
                    
NuGet\Install-Package EFDoctor.Analyzers -Version 0.6.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="EFDoctor.Analyzers" Version="0.6.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EFDoctor.Analyzers" Version="0.6.0" />
                    
Directory.Packages.props
<PackageReference Include="EFDoctor.Analyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 EFDoctor.Analyzers --version 0.6.0
                    
#r "nuget: EFDoctor.Analyzers, 0.6.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 EFDoctor.Analyzers@0.6.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=EFDoctor.Analyzers&version=0.6.0
                    
Install as a Cake Addin
#tool nuget:?package=EFDoctor.Analyzers&version=0.6.0
                    
Install as a Cake Tool

EFDoctor.Analyzers

Roslyn analyzers that find EF Core performance and correctness problems in every build and in the IDE.

They report evidence-based findings, such as SaveChanges inside a loop, a query materialized before filtering, a synchronous database call in async code, or an EF Core task that is never awaited. Everything runs inside the compiler: there is no telemetry, network call, or source upload.

These are the same rules as the EFDoctor command-line tool. Use the tool for a full report with evidence, likely impact, and remediation, or for JSON output in CI. Use this package to see findings while you write code.

0.x. Rules and defaults may still change before 1.0.

Install

dotnet add package EFDoctor.Analyzers

Or once for every project, with central package management:


<PackageVersion Include="EFDoctor.Analyzers" Version="x.y.z" />


<ItemGroup>
  <PackageReference Include="EFDoctor.Analyzers" PrivateAssets="all" />
</ItemGroup>

The analyzers need the .NET 8 SDK or later, or Visual Studio 2022 17.8 or later. The project can target any framework.

Severities

Each finding has a confidence, and its default severity follows it:

Confidence Default severity
High warning (suggestion for the cleanup rule EFD025)
Medium suggestion
Advisory suggestion

So only high-confidence findings can fail a build that treats warnings as errors. Change a rule's severity in .editorconfig:

[*.cs]
dotnet_diagnostic.EFD010.severity = warning   # raise a medium-confidence rule
dotnet_diagnostic.EFD023.severity = none      # turn a rule off

Test projects

Test projects are skipped: a project with IsTestProject set to true, or one that references xunit, NUnit, the Visual Studio test platform, or Microsoft.NET.Test.Sdk. To analyze one anyway, set this in its project file:

<PropertyGroup>
  <EFDoctorAnalyzeTestProjects>true</EFDoctorAnalyzeTestProjects>
</PropertyGroup>

Rules and suppression

The rules are listed with their confidence in the project README. Every diagnostic links to its rule page, which describes what triggers the rule, what deliberately doesn't, and the fix. Suppress an intentional finding with standard Roslyn mechanisms (#pragma warning disable EFD001, .editorconfig, or [SuppressMessage]), and record why.

Code fixes

For the mechanical remediations, the IDE offers a quick action that applies the fix. Four are available so far:

  • EFD002: replace a count compared for existence with Any, or its negation.
  • EFD010: await the async counterpart of the synchronous call, passing a CancellationToken in scope.
  • EFD019: drop the materialization and reduce in the query, in async form when it was awaited.
  • EFD029: replace the discarding OrderBy with ThenBy.

The fixes ship in this package, in EFDoctor.CodeFixes.dll, which only IDEs load. The command-line build ignores it.

License

Apache-2.0. See the NOTICE file included in the package.

There are no supported framework assets in this package.

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
0.6.0 105 10/19/2026
0.5.0 97 10/18/2026
0.4.0 583 10/6/2026

0.6.0: ten new rules, for 36 in all, among them EFD031 (LINQ over a stored-procedure call), EFD032 (change to an AsNoTracking entity that is never saved), EFD033 (DbContext captured by a singleton), EFD034 (EnsureCreated with migrations), and EFD035 and EFD036, which read the model snapshot. The first code fixes ship in the analyzers package, for EFD002, EFD010, EFD019, and EFD029. EFD006 now honors a split-query default, and test-project detection no longer skips projects that only reference an assertion library. See CHANGELOG.md in the package.