ef-core
Installation
SKILL.md
EF Core (.NET 10)
Targets EF Core 10 (LTS, supported until 2028-11-10). New-in-10 details, SQL output and the EF Core 11 note live in references/ef-core-10.md.
Core Principles
- EF Core is the default ORM — Use it unless you have a specific reason not to (extreme perf, legacy DB without FK constraints). See ADR-003.
- DbContext is a unit of work — Don't wrap it in another UoW or repository. It already is one.
- Reads are projections —
.Select()into DTOs. No tracking, no over-fetching, no N+1. If you must return entities from a read, addAsNoTracking(). - Writes are tracked entities or bulk
ExecuteUpdate/ExecuteDelete— Never load rows just to change one column. - Migrations are code — Review them, test them, never auto-apply in production.
Patterns
DbContext Configuration
Use IEntityTypeConfiguration<T> per entity; keep the context thin.