ef-core

Configures DbContext, optimizes queries, and manages migrations for .NET 10.

640|145|Updated Feb 20, 2026
One-click install
npx skills add https://github.com/codewithmukesh/dotnet-claude-kit --skill ef-core-codewithmukesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ef-core
Source: https://github.com/codewithmukesh/dotnet-claude-kit/tree/main/skills/ef-core
Command: npx skills add https://github.com/codewithmukesh/dotnet-claude-kit --skill ef-core-codewithmukesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides actionable guidance to avoid common Entity Framework Core pitfalls such as N+1 queries, over-fetching, unsafe migrations, and improper DbContext usage, enabling maintainable and performant data access in .NET 10 projects.

Core Features & Use Cases

  • DbContext configuration: patterns for registering contexts, using IEntityTypeConfiguration, and organizing persistence code.
  • Query optimization: projection-first queries, compiled queries for hot paths, and guidance to avoid ToListAsync-before-filter anti-patterns.
  • Bulk operations & migrations: when to use ExecuteUpdateAsync/ExecuteDeleteAsync, safe migration workflows and production-ready scripts.
  • Cross-cutting concerns: interceptors for auditing and soft deletes, global query filters for multi-tenancy, and value converters for strongly-typed IDs.
  • Decision guidance & anti-patterns: recommendations on repositories vs. direct DbContext usage, lazy loading pitfalls, and reporting vs. raw SQL trade-offs.

Quick Start

Ask the assistant to review a specific EF Core query or migration in your .NET 10 project and provide optimized code and migration guidance.

Frequently Asked Questions about ef-core

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

FAQPage Schema
How do I optimize EF Core queries to avoid N+1 issues and over-fetching in .NET 10?

To optimize EF Core queries, use projection-first queries to select only necessary DTO fields and avoid ToListAsync-before-filter anti-patterns. Apply compiled queries for hot paths to reduce query compilation overhead and improve data access performance.

What is the best way to manage safe EF Core migrations for production databases?

Safe EF Core migrations require production-ready scripts and careful workflow management. You should generate idempotent scripts and review migration steps to prevent data loss, ensuring schema changes are applied safely without downtime or unsafe operations.

How do I configure a DbContext for multi-tenancy and soft deletes using EF Core interceptors?

Configuring DbContext for multi-tenancy and soft deletes involves applying global query filters to isolate tenant data and using interceptors for auditing. This cross-cutting approach ensures deleted records are hidden and tenant boundaries are enforced automatically.

When should I use ExecuteUpdateAsync and ExecuteDeleteAsync instead of standard SaveChanges in EF Core?

Use ExecuteUpdateAsync and ExecuteDeleteAsync for bulk operations when you need to modify or delete large datasets without loading entities into memory. These commands run directly against the database, bypassing the change tracker for high-throughput updates.

Does EF Core support value converters for strongly-typed IDs and how do I implement them?

Yes, EF Core supports value converters to map strongly-typed IDs to primitive database columns. You configure converters in your entity configurations to translate custom ID structures during database reads and writes, maintaining domain model type safety.

Why does lazy loading cause performance pitfalls and should I use repositories or direct DbContext usage?

Lazy loading causes performance pitfalls by triggering unexpected database queries during entity traversal. Direct DbContext usage is often preferred over the repository pattern for data access, reducing abstraction overhead while maintaining testable query logic.