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
<PackageReference Include="Bitbean.Analyzers.EfCore" Version="1.0.1"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Bitbean.Analyzers.EfCore" Version="1.0.1" />
<PackageReference Include="Bitbean.Analyzers.EfCore"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Bitbean.Analyzers.EfCore --version 1.0.1
#r "nuget: Bitbean.Analyzers.EfCore, 1.0.1"
#:package Bitbean.Analyzers.EfCore@1.0.1
#addin nuget:?package=Bitbean.Analyzers.EfCore&version=1.0.1
#tool nuget:?package=Bitbean.Analyzers.EfCore&version=1.0.1
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
- Install the NuGet package
- Analyzers automatically detect issues in your EF Core code
- Use
Ctrl+.
in Visual Studio to apply automatic code fixes - 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.
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.
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