ef-core

Reviews Entity Framework Core code and recommends best practices for .NET data access.

Updated Jul 21, 2026
One-click install
npx skills add https://github.com/afonsoft/gamehub --skill ef-core-afonsoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ef-core
Source: https://github.com/afonsoft/gamehub/tree/main/.claude/skills/ef-core
Command: npx skills add https://github.com/afonsoft/gamehub --skill ef-core-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working with Entity Framework Core often struggle with performance pitfalls like N+1 queries, poorly designed migrations, and incorrect change tracking. This Skill provides structured best-practice guidance to review and improve EF Core data access code in .NET applications. ## Core Features & Use Cases - Data Context & Entity Design: Guidance on focused DbContext classes, IEntityTypeConfiguration separation, relationships, and owned entity types. - Performance & Querying: Recommendations for AsNoTracking, pagination, eager loading with Include, projections, compiled queries, and avoiding N+1 problems. - Migrations, Security & Testing: Practices for small descriptive migrations, parameterized queries to prevent SQL injection, and testing with in-memory or SQLite providers. - Use Case: When reviewing a repository layer that fetches orders with related line items, the Skill identifies missing Include() calls causing N+1 queries and suggests eager loading plus AsNoTracking for read-only scenarios. ## Quick Start Review my EF Core DbContext and repository code and suggest improvements following best practices.

Frequently Asked Questions about ef-core

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid N+1 query problems in Entity Framework Core?▼

Use Include() to eager load related entities in a single query instead of letting lazy loading trigger separate queries per row. Combine this with projection via Select to retrieve only required fields when full entities are unnecessary.

How to improve EF Core query performance for read-only data?▼

Apply AsNoTracking() to read-only queries so EF Core skips change tracking overhead. Add pagination with Skip() and Take() for large result sets, and consider compiled queries for frequently executed statements.

Should I use in-memory database or SQLite for EF Core testing?▼

Use the in-memory provider for fast unit tests where relational behavior is not required. Use SQLite in in-memory mode for integration tests because it supports real relational semantics like foreign keys and transactions.

What are EF Core migration best practices for production?▼

Create small, focused migrations with descriptive names and verify the generated SQL scripts before applying them to production. Consider migration bundles for deployment and add data seeding through migrations when appropriate.

When should I use raw SQL instead of LINQ in EF Core?▼

Prefer strongly-typed LINQ queries for maintainability, and reserve raw SQL for complex operations that LINQ cannot express efficiently. Always use parameterized queries with raw SQL to prevent SQL injection.