--- name: efcore-review description: Use when reviewing Entity Framework Core LINQ queries, models, migrations, or persistence behavior for correctness, provider behavior, performance, and data-scope risks. --- # EF Core Review Use when reviewing Entity Framework Core queries, model changes, migrations, or persistence behavior. Load and follow `rules-csharp-security` and `rules-csharp-architecture-and-apis` for the matching C# rules. ## Review - Check whether LINQ translates as intended for the configured provider and whether filters are applied before materialization. - Look for N+1 access, unbounded result sets, unnecessary tracking, duplicate queries, and over-fetching. Flag cartesian explosion from multiple collection includes where `AsSplitQuery` fits. - Flag `FromSqlRaw` or `ExecuteSqlRaw` built by string concatenation or interpolation; use the parameterized `FromSql` or `ExecuteSql` forms. - Flag `IgnoreQueryFilters` that bypasses tenant or soft-delete filters without an explicit, authorized reason. - Check `DbContext` lifetime: no singleton or static context, no sharing across threads or parallel tasks. - Review relationship configuration, delete behavior, keys, nullability, indexes, and concurrency tokens against the domain invariants. - Check migration ordering, generated SQL, data backfills, rollback limits, and compatibility while old and new application versions coexist. - Inspect transaction scope, isolation, retry behavior, cancellation, and concurrency conflict handling where applicable. Report findings in the `review-pull-request` finding schema and severity scale. Avoid recommending indexes or caching without evidence of a query need.