postpartum-genushyacinthus29/dotnet-skills/dotnet-entity-framework-core
Claude Code and agent skill by postpartum-genushyacinthus29/dotnet-skills
- community
Checking that the SKILL.md file is still in the repository.
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications.
Install
npx vskill@latest install postpartum-genushyacinthus29/dotnet-skills/dotnet-entity-framework-coreSKILL.md
The same SKILL.md was published earlier as postpartum-genushyacinthus29/dotnet-skills/dotnet-entity-framework-core.
Entity Framework Core
Trigger On
- working on
DbContext, migrations, model configuration, or EF queries - reviewing tracking, loading, performance, or transaction behavior
- porting data access from EF6 or custom repositories to EF Core
- optimizing slow database queries
Documentation
References
- patterns.md - Query patterns, tracking strategies, loading strategies, projections, compiled queries, pagination, and temporal tables
- anti-patterns.md - Common EF Core mistakes including N+1 queries, large contexts, generic repositories, and missing indexes
Workflow
- Prefer EF Core for new development unless a documented gap requires Dapper or raw SQL
- Keep `DbContext` lifetime scoped — align with unit of work
- Review query translation — check generated SQL, avoid N+1
- Treat migrations as first-class — reviewable, not throwaway
- Be deliberate about provider behavior — cross-provider but not identical
- Validate with query inspection — not just in-memory mental model
DbContext Patterns
Basic Configuration
Registration with DI
Query Patterns
Use AsNoTracking for Read-Only
Project to DTOs
Avoid N+1 Queries
Compiled Queries (EF Core 9)
Migration Patterns
Creating Migrations
Data Migrations
Anti-Patterns to Avoid
| Anti-Pattern | Why It's Bad | Better Approach | |
|---|---|---|---|
ToList() then filter | Loads all data to memory | Filter in query | |
| Multiple DbContext per request | Transaction issues | Scoped lifetime | |
| Lazy loading everywhere | N+1 queries | Explicit Include | |
| Generic repository wrapper | Removes query power | Use DbContext directly | |
| Ignoring generated SQL | Hidden performance issues | Log and review | |
SaveChanges() in loops | Many roundtrips | Batch then save |
Performance Best Practices
- Index frequently queried columns:
``csharp builder.HasIndex(p => p.CreatedAt); builder.HasIndex(p => new { p.Category, p.Status }); ``
- Use pagination:
``csharp var page = await db.Products .OrderBy(p => p.Id) .Skip(pageSize * pageNumber) .Take(pageSize) .ToListAsync(); ``
- Batch updates (EF Core 7+):
```csharp await db.Products .Where(p => p.Category == "Obsolete") .ExecuteDeleteAsync();
await db.Products .Where(p => p.Category == "Sale") .ExecuteUpdateAsync(p => p.SetProperty(x => x.Price, x => x.Price * 0.9m)); ```
- Minimize network roundtrips:
```csharp // Bad - 3 roundtrips var product = await db.Products.FindAsync(id); var reviews = await db.Reviews.Where(r => r.ProductId == id).ToListAsync(); var related = await db.Products.Where(p => p.Category == product.Category).ToListAsync();
// Good - 1 roundtrip var data = await db.Products .Where(p => p.Id == id) .Select(p => new { Product = p, Reviews = p.Reviews, Related = db.Products.Where(r => r.Category == p.Category).Take(5) }) .FirstOrDefaultAsync(); ```
Concurrency Patterns
Deliver
- EF Core models and queries that match the domain
- safer migrations and lifetime management
- performance-aware data access decisions
- proper indexing and query optimization
Validate
- query behavior is intentional (check SQL logs)
- migrations are reviewable and correct
- no N+1 queries in common paths
- indexes exist for filtered/sorted columns
- DbContext lifetime is scoped properly
- concurrency is handled for critical entities
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dotnet-entity-framework-core/SKILL.md
Popularity
- Repository stars
- 6
- 7-day trend score
- 10
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/postpartum-genushyacinthus29/dotnet-skills/dotnet-entity-framework-core)