
Ef Core
Apply Entity Framework Core patterns for DbContext design, queries, migrations, and performance when building or hardening a .NET data layer.
Overview
ef-core is an agent skill most often used in Build (also Ship when applying migrations) that encodes Entity Framework Core best practices for context design, entities, performance, migrations, and querying.
Install
npx skills add https://github.com/github/awesome-copilot --skill ef-coreWhat is this skill?
- DbContext design: focused contexts, OnModelCreating, IEntityTypeConfiguration, DbContextFactory for tests
- Entity modeling: keys, relationships, owned types, annotations vs fluent API
- Performance: AsNoTracking, pagination, Include vs projection, compiled queries, N+1 avoidance
- Migrations: small focused migrations, descriptive names, SQL review, bundles, seeding
- Querying guidance centered on IQueryable best practices
Adoption & trust: 8.9k installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are building or changing a .NET API with EF Core and need consistent patterns so queries stay fast and migrations do not endanger production.
Who is it for?
Solo builders shipping ASP.NET Core or .NET APIs who want an agent to enforce EF Core structure during feature work and schema changes.
Skip if: Teams on Dapper-only stacks, non-.NET backends, or greenfield apps with no relational data layer yet.
When should I use this skill?
Working with Entity Framework Core on models, queries, or migrations and you want best-practice defaults applied.
What do I get? / Deliverables
Your agent applies focused DbContext rules, entity relationship conventions, and performance-minded query habits aligned with EF Core recommendations.
- EF Core-aligned model and query recommendations
- Migration and performance guidance in chat or docs
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
EF Core work is core backend product construction; migrations and query tuning also matter at ship/operate, but the canonical shelf is Build → backend. The skill is entirely about ORM, entities, migrations, and IQueryable patterns—backend data access, not frontend or DevOps wiring alone.
Where it fits
Shape a new feature’s entities and DbContext configurations before the first API endpoint ships.
Review migration SQL and naming before deploying schema changes to staging or production.
Refactor hot read paths with AsNoTracking and projection after latency shows up in logs.
How it compares
Use as an in-session EF Core playbook instead of generic “write clean code” prompts that ignore N+1 and migration safety.
Common Questions / FAQ
Who is ef-core for?
Indie and solo developers using Entity Framework Core in .NET web APIs or services who want agent-guided conventions for models, queries, and migrations.
When should I use ef-core?
During Build when designing DbContexts and entities, when optimizing read queries, and in Ship when authoring or reviewing EF migrations before production.
Is ef-core safe to install?
It is guidance-only with no built-in shell or network calls; review the Security Audits panel on this Prism page before installing from any third-party skill source.
SKILL.md
READMESKILL.md - Ef Core
# Entity Framework Core Best Practices Your goal is to help me follow best practices when working with Entity Framework Core. ## Data Context Design - Keep DbContext classes focused and cohesive - Use constructor injection for configuration options - Override OnModelCreating for fluent API configuration - Separate entity configurations using IEntityTypeConfiguration - Consider using DbContextFactory pattern for console apps or tests ## Entity Design - Use meaningful primary keys (consider natural vs surrogate keys) - Implement proper relationships (one-to-one, one-to-many, many-to-many) - Use data annotations or fluent API for constraints and validations - Implement appropriate navigational properties - Consider using owned entity types for value objects ## Performance - Use AsNoTracking() for read-only queries - Implement pagination for large result sets with Skip() and Take() - Use Include() to eager load related entities when needed - Consider projection (Select) to retrieve only required fields - Use compiled queries for frequently executed queries - Avoid N+1 query problems by properly including related data ## Migrations - Create small, focused migrations - Name migrations descriptively - Verify migration SQL scripts before applying to production - Consider using migration bundles for deployment - Add data seeding through migrations when appropriate ## Querying - Use IQueryable judiciously and understand when queries execute - Prefer strongly-typed LINQ queries over raw SQL - Use appropriate query operators (Where, OrderBy, GroupBy) - Consider database functions for complex operations - Implement specifications pattern for reusable queries ## Change Tracking & Saving - Use appropriate change tracking strategies - Batch your SaveChanges() calls - Implement concurrency control for multi-user scenarios - Consider using transactions for multiple operations - Use appropriate DbContext lifetimes (scoped for web apps) ## Security - Avoid SQL injection by using parameterized queries - Implement appropriate data access permissions - Be careful with raw SQL queries - Consider data encryption for sensitive information - Use migrations to manage database user permissions ## Testing - Use in-memory database provider for unit tests - Create separate testing contexts with SQLite for integration tests - Mock DbContext and DbSet for pure unit tests - Test migrations in isolated environments - Consider snapshot testing for model changes When reviewing my EF Core code, identify issues and suggest improvements that follow these best practices.