ef-core

Apply Entity Framework Core best practices for DbContext configuration, queries, and migrations.

Updated Apr 27, 2026
One-click install
npx skills add https://github.com/shahdanish/vibepos --skill ef-core-shahdanish
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ef-core
Source: https://github.com/shahdanish/vibepos/tree/main/skills/ef-core
Command: npx skills add https://github.com/shahdanish/vibepos --skill ef-core-shahdanish

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you build reliable, high-performance data access with Entity Framework Core by preventing common pitfalls that lead to slow queries, excessive loading, and fragile migrations.

Core Features & Use Cases

  • DbContext configuration patterns: Use IEntityTypeConfiguration<T> and ApplyConfigurationsFromAssembly to keep mappings maintainable and discoverable.
  • Production-ready query design: Prefer projections (Select to DTOs) to avoid over-fetching and N+1 problems, plus pagination patterns for scalable list endpoints.
  • Performance and correctness tools: Use ExecuteUpdateAsync/ExecuteDeleteAsync, interceptors for audit/soft-delete concerns, compiled queries for hot paths, value converters for strongly-typed IDs/enums, and global query filters to enforce invariants.
  • Migrations workflow guidance: Treat migrations as code—review before applying, test, and generate idempotent SQL for production instead of auto-migrating.

Use Case Example: You are building a sales/reporting screen for a POS system and need a list of orders with item summaries without loading full entities or suffering N+1 queries; you also want bulk status updates and safe schema changes across environments.

Quick Start

Ask the AI to show an EF Core DbContext setup with IEntityTypeConfiguration, then write a projected LINQ query with pagination that avoids N+1 and prepares a migration command workflow.

Frequently Asked Questions about ef-core

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

FAQPage Schema
How do I prevent N+1 queries and over-fetching with EF Core?

Prevent EF Core N+1 queries by using projection-based querying with `Select` to map entities directly into DTOs. This approach avoids loading full entities and ensures only necessary data is retrieved.

What is the best way to handle bulk updates and deletes in EF Core?

The best way to handle bulk updates and deletes in EF Core is using `ExecuteUpdateAsync` and `ExecuteDeleteAsync`. These methods perform operations directly in the database, bypassing entity tracking overhead for better performance.

How do I configure DbContext in EF Core for maintainable entity mappings?

Configure DbContext for maintainable mappings by applying `IEntityTypeConfiguration<T>` classes and registering them with `ApplyConfigurationsFromAssembly`. This keeps entity mapping logic discoverable and separated from the DbContext setup.

When should I use compiled queries in EF Core?

Use compiled queries in EF Core for hot-path querying scenarios where the same LINQ query executes repeatedly. They improve performance by caching the query translation, reducing the overhead of parsing and compiling on each run.

How do I manage EF Core migrations safely across production environments?

Manage EF Core migrations safely by treating them as code: review generated SQL before applying, test locally, and generate idempotent SQL for production. Avoid auto-migrating in production to prevent fragile schema changes.

Can I implement audit logging and soft deletes using EF Core interceptors?

Yes, you can implement audit logging and soft deletes using EF Core interceptors. Interceptors allow you to hook into data access operations to automatically populate audit fields or apply global query filters for excluded records.