Bitbean.Analyzers.EfCore 1.0.1

dotnet add package Bitbean.Analyzers.EfCore --version 1.0.1
                    
NuGet\Install-Package Bitbean.Analyzers.EfCore -Version 1.0.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="Bitbean.Analyzers.EfCore" Version="1.0.1">
  <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="Bitbean.Analyzers.EfCore" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Bitbean.Analyzers.EfCore">
  <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 Bitbean.Analyzers.EfCore --version 1.0.1
                    
#r "nuget: Bitbean.Analyzers.EfCore, 1.0.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 Bitbean.Analyzers.EfCore@1.0.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=Bitbean.Analyzers.EfCore&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Bitbean.Analyzers.EfCore&version=1.0.1
                    
Install as a Cake Tool

Bitbean.Analyzers.EfCore

Custom Roslyn analyzers for Entity Framework Core performance and best practices.

🎯 Analyzers Included

EFCORE001 - IReadOnlySet.Contains Analyzer

Detects IReadOnlySet<T>.Contains() usage in EF Core queries that may not translate to SQL.

❌ Problematic:

IReadOnlySet<int> allowedIds = new HashSet<int> { 1, 2, 3 };
var users = context.Users.Where(u => allowedIds.Contains(u.Id)).ToList();

✅ Fixed:

HashSet<int> allowedIds = new HashSet<int> { 1, 2, 3 };
var users = context.Users.Where(u => allowedIds.ToArray().Contains(u.Id)).ToList();

EFCORE002 - GroupBy without Select Analyzer

Detects GroupBy() without Select() that causes EF Core to load all data and group in memory.

❌ Problematic:

var result = context.Users.GroupBy(u => u.Department).ToList();

✅ Fixed:

var result = context.Users
    .GroupBy(u => u.Department)
    .Select(g => new { Department = g.Key, Count = g.Count() })
    .ToList();

🔧 Automatic Code Fixes

Both analyzers include automatic code fixes:

  • EFCORE001: "Wrap set with ToArray()"
  • EFCORE002: Multiple options including placeholder for aggregations, keys only, and Count example

📦 Installation

<PackageReference Include="Bitbean.Analyzers.EfCore" Version="1.0.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

🚀 Usage

  1. Install the NuGet package
  2. Analyzers automatically detect issues in your EF Core code
  3. Use Ctrl+. in Visual Studio to apply automatic code fixes
  4. Build warnings will guide you to performance improvements

📚 Documentation

This README contains all the essential information for using the analyzers. Additional documentation and examples may be made available in the future.

🤝 Contributing

This project is currently maintained privately by Bitbean. We may consider opening it for community contributions in the future. For now, please report issues or suggestions through NuGet.org package feedback.

📄 License

MIT License - see the repository for details.

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
1.0.1 540 7/7/2025
1.0.0 221 7/7/2025 1.0.0 is deprecated because it has critical bugs.

v1.0.1:
     - Fixed package resolution issues
     - Improved analyzer packaging structure

     v1.0.0:
     - EFCORE001: Detects IReadOnlySet<T>.Contains() usage that may not translate to SQL
     - EFCORE002: Detects GroupBy() without Select() that causes in-memory grouping
     - Automatic code fixes for both analyzers
     - Comprehensive test coverage