ef-core
Entity Framework Core patterns for .NET 10. Covers DbContext configuration, migrations workflow, interceptors, compiled queries, ExecuteUpdateAsync, ExecuteDeleteAsync, value converters, and query optimization. Load this skill when working with databases, writing queries, managing schema changes, or
By codewithmukesh · 1,204 installs
npx skills add codewithmukesh/dotnet-claude-kit --skill ef-core
Source repository · Upstream listing
EF Core (.NET 10)
Core Principles
1. 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.
2. DbContext is a unit of work — Don't wrap it in another UoW abstraction. EF Core already implements Unit of Work and Repository patterns internally.
3. Queries should be projections — Use .Select() to project into DTOs instead of loading full entities. This avoids over fetching and N+1 issues.
4. Migrations are code — Treat them like any other source code. Review them, test them, never auto apply in production.
Patterns
DbContext Configuration
Use IEntityTypeConfiguration<T to keep entity configs separate and discoverable.
Registration
Query Projections (Avoid Over Fetching)
Pagination
ExecuteUpdateAsync / ExecuteDeleteAsync
Bulk operations that bypass change tracking for better performance.
Interceptors
Use interceptors for cross cutting concerns like audit trails and soft deletes.
Compiled Queries
Use for hot path queries that execute frequently with the same shape.
Value Converters
Migrations Workflow
Global Query Filters
Anti patterns
Don't Wrap DbContext in a Repository
Don't Use Lazy Loading
Don't Use .ToListAsync() Then Filter in Memory
Don't Forget to Await Async Methods
Decision Guide
Scenario Recommendation
Standard CRUD DbContext with projections
Bulk updates (100+ rows) ExecuteUpdateAsync / ExecuteDeleteAsync
Hot path read query Compiled query
Complex reporting query Raw SQL with FromSqlInterpolated or Dapper
Audit trails SaveChangesInterceptor
Multi tenancy Global query filter
Soft deletes Global query filter + interceptor
Strongly typed IDs Value converter
Production migration Idempotent SQL script, never auto migrate