What problem does it solve?
This guide solves common EF Core pitfalls that cause memory bloat, incorrect DbContext usage, inefficient queries, and unsafe migration workflows by prescribing lifetime, tracking, and resiliency patterns for reliable data access in .NET applications.
Core Features & Use Cases
- Scoped DbContext lifecycle guidance and IDbContextFactory usage for background services and Blazor Server to avoid captured or long-lived contexts.
- Read optimization with AsNoTracking and context-level QueryTrackingBehavior to reduce memory and CPU for read-heavy services.
- Query splitting recommendations to prevent Cartesian explosion when including multiple collection navigations and tradeoffs between atomicity and round-trips.
- Migration workflows and migration bundle instructions for safe production deployments along with best practices around idempotent scripts and avoiding Database.Migrate at startup.
- Interceptors, compiled queries, and connection resiliency patterns for automatic auditing, soft deletes, high-frequency query optimization, and transient failure retries.
- Use case: converting a synchronous order-report endpoint that loads orders with multiple child collections into an efficient, read-only, split-query flow registered on a scoped DbContext.
Quick Start
Show me how to register a scoped AppDbContext, enable AsNoTracking defaults for read-only services, and convert an Include-heavy query to use AsSplitQuery to avoid Cartesian explosion.