Rule reference
LinqContraband Rule Catalog
Full LinqContraband EF Core analyzer rule catalog grouped by query, materialization, loading, async, tracking, raw SQL, and schema design.
The source of truth for rule metadata lives in src/LinqContraband/Catalog/RuleCatalog.cs. This page is generated from that catalog and grouped by EF Core failure mode.
8 diagnostic domains
Bulk Operations & Set-Based Writes
Keep destructive and high-volume writes set-based while making the risky cases explicit.
Optimize: Use ExecuteDelete() instead of RemoveRange()
Samples/LC012_OptimizeRemoveRange/ LC032 InfoUse ExecuteUpdate for provable bulk scalar updates
Samples/LC032_ExecuteUpdateForBulkUpdates/ LC035 InfoMissing Where before bulk execute
Samples/LC035_MissingWhereBeforeExecuteDeleteUpdate/Change Tracking & Context Lifetime
Spot DbContext lifetime leaks, tracking-mode surprises, and writes that silently do nothing.
Performance: Missing AsNoTracking() in Read-Only path
Samples/LC009_MissingAsNoTracking/ LC010 WarningN+1 Write Problem: SaveChanges inside loop
Samples/LC010_SaveChangesInLoop/ LC013 WarningDisposed Context Query
Samples/LC013_DisposedContextQuery/ LC025 WarningAvoid AsNoTracking with Update/Remove
Samples/LC025_AsNoTrackingWithUpdate/ LC030 InfoPotential DbContext lifetime mismatch
Samples/LC030_DbContextInSingleton/ LC039 InfoAvoid repeated SaveChanges on the same context
Samples/LC039_NestedSaveChanges/ LC040 InfoAvoid mixing tracking modes on the same context
Samples/LC040_MixedTrackingAndNoTracking/ LC044 WarningAsNoTracking query mutated then SaveChanges — silent data loss
Samples/LC044_AsNoTrackingThenModify/Execution & Async
Find synchronous calls, repeated database execution, and async paths that drop cancellation or buffer too early.
N+1 Problem: Database execution inside loop
Samples/LC007_NPlusOneLooper/ LC008 WarningSync-over-Async: Synchronous EF Core method in Async context
Samples/LC008_SyncBlocker/ LC026 InfoMissing CancellationToken in async call
Samples/LC026_MissingCancellationToken/ LC036 WarningDbContext captured by thread work item
Samples/LC036_DbContextCapturedAcrossThreads/ LC043 InfoPrefer await foreach over buffering async streams
Samples/LC043_AsyncEnumerableBuffering/Loading & Includes
Make relationship loading deliberate before N+1 round trips or over-eager include graphs reach production.
Cartesian Explosion Risk: Multiple Collection Includes
Samples/LC006_CartesianExplosion/ LC019 WarningConditional Include Expression
Samples/LC019_ConditionalInclude/ LC028 WarningDeep ThenInclude Chain
Samples/LC028_DeepThenInclude/ LC038 InfoAvoid excessive eager loading
Samples/LC038_ExcessiveEagerLoading/ LC042 InfoComplex query should be tagged
Samples/LC042_MissingQueryTags/ LC045 WarningMissing Include: navigation accessed on materialized entity
Samples/LC045_MissingInclude/Materialization & Projection
Keep work in SQL where it belongs and avoid loading whole entities or unbounded result sets by accident.
Premature query continuation after materialization
Samples/LC002_PrematureMaterialization/ LC003 WarningPrefer Any() over Count() existence checks
Samples/LC003_AnyOverCount/ LC017 InfoPerformance: Consider using Select() projection
Samples/LC017_WholeEntityProjection/ LC022 InfoNested collection materialization inside projection
Samples/LC022_ToListInSelectProjection/ LC023 InfoUse Find/FindAsync for primary key lookups
Samples/LC023_FindInsteadOfFirstOrDefault/ LC029 InfoRedundant identity Select
Samples/LC029_RedundantIdentitySelect/ LC031 InfoUnbounded Query Materialization
Samples/LC031_UnboundedQueryMaterialization/ LC033 InfoUse FrozenSet for provably read-only membership caches
Samples/LC033_UseFrozenSetForStaticMembershipCaches/ LC041 InfoSingle entity query over-fetches one consumed property
Samples/LC041_SingleEntityScalarProjection/Query Shape & Translation
Catch LINQ patterns that EF Core cannot translate reliably or cannot page deterministically.
Client-side evaluation risk: Local method usage in IQueryable
Samples/LC001_LocalMethod/ LC004 WarningDeferred Execution Leak: IQueryable passed as IEnumerable
Samples/LC004_IQueryableLeak/ LC005 WarningMultiple OrderBy calls
Samples/LC005_MultipleOrderBy/ LC014 WarningAvoid String.ToLower() or ToUpper() in LINQ queries
Samples/LC014_AvoidStringCaseConversion/ LC015 WarningDeterministic Pagination: OrderBy required before Skip/Take
Samples/LC015_MissingOrderBy/ LC016 WarningAvoid DateTime.Now/UtcNow in LINQ queries
Samples/LC016_AvoidDateTimeNow/ LC020 WarningAvoid untranslatable string comparison overloads
Samples/LC020_StringContainsWithComparison/ LC024 WarningGroupBy with Non-Translatable Projection
Samples/LC024_GroupByNonTranslatable/Raw SQL & Security
Flag SQL construction patterns that can bypass parameterization, tenant filters, or review expectations.
Avoid FromSqlRaw with interpolated strings
Samples/LC018_AvoidFromSqlRawWithInterpolation/ LC021 WarningAvoid IgnoreQueryFilters
Samples/LC021_AvoidIgnoreQueryFilters/ LC034 WarningAvoid ExecuteSqlRaw with interpolated strings
Samples/LC034_AvoidExecuteSqlRawWithInterpolation/ LC037 WarningAvoid constructed raw SQL strings
Samples/LC037_RawSqlStringConstruction/Schema & Modeling
Guard model shape choices that produce fragile entity mappings and unclear relationships.