What problem does it solve?
This skill codifies best practices for EF Core usage to maximize performance, reliability, and maintainability across data access layers. It addresses common pitfalls such as unnecessary tracking, manual migration edits, and inconsistent transaction handling, providing a structured approach to configure DbContext, migrations, and data access patterns.
Core Features & Use Cases
- NoTracking by default for read-only queries to improve performance; explicit tracking or Update when needed.
- Never edit migrations manually; rely on EF Core CLI for creating, applying, and scripting migrations.
- Dedicated migration service with Aspire to run migrations before app startup and clean seeding behavior.
- Execution strategies for transient failures with retry policies and safe transaction usage inside strategy callbacks.
- Bulk operations using ExecuteUpdate/ExecuteDelete to perform set-based updates and deletes without loading entities.
- Global query splitting to prevent cartesian explosion when loading multiple navigation collections; per-query override possible.
- Guidance on DbContext lifetime (scoped per request in ASP.NET Core, or per operation in background/actors with scope or factory).
- Testing recommendations with EF Core; in-memory provider for unit tests; testcontainers for integration tests.
Quick Start
To implement EF Core patterns in your app, configure your DbContext with NoTracking default, enable query splitting globally, set up a dedicated migration service for Aspire, and adopt bulk operations for large updates. See example usage in the Skill notes for concrete code changes and commands.