One-click install
npx skills add https://github.com/Trossitec/dotnet-claude-kit --skill ef-core-trossitec
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ef-core
Source: https://github.com/Trossitec/dotnet-claude-kit/tree/main/skills/ef-core
Command: npx skills add https://github.com/Trossitec/dotnet-claude-kit --skill ef-core-trossitec

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you implement Entity Framework Core in a way that avoids common performance traps and correctness issues, so your .NET app queries, migrations, and bulk operations stay efficient as your schema and codebase grow.

Core Features & Use Cases

  • DbContext configuration with discoverable entity mappings: Use IEntityTypeConfiguration<T> and ApplyConfigurationsFromAssembly to keep model configuration maintainable.
  • Query optimization that prevents over-fetching and N+1: Prefer projections via .Select() and avoid loading unnecessary data.
  • Production-grade database workflows: Review and apply migrations like code, generate idempotent SQL scripts for production, and use global query filters for soft deletes and multi-tenancy.
  • Performance primitives for hot paths: Use ExecuteUpdateAsync/ExecuteDeleteAsync for bulk operations, SaveChangesInterceptor for audit/soft-delete cross-cutting concerns, and compiled queries for frequently repeated query shapes.
  • Data modeling improvements: Apply value converters (e.g., enums as strings, strongly-typed IDs) and use precision/constraints intentionally.

Quick Start

When you are working on an EF Core task, ask the assistant to generate or refactor your DbContext configuration and the specific query (including projections, pagination, and any needed interceptors or bulk operations) to match modern .NET 10 practices.

Frequently Asked Questions about ef-core

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

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

To fix N+1 query problems in EF Core, use projections with `.Select()` to fetch only the required fields instead of loading entire entities and related collections. This prevents over-fetching and optimizes hot-path read scenarios.

What is the best way to perform bulk updates and deletes with EF Core?

The best way to perform bulk updates and deletes in EF Core is using `ExecuteUpdateAsync` and `ExecuteDeleteAsync`. These execute directly against the database, bypassing the DbContext change tracker for efficient bulk workflows.

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

Configure DbContext for maintainable entity mappings by implementing `IEntityTypeConfiguration<T>` and calling `ApplyConfigurationsFromAssembly`. This keeps model configuration isolated and discoverable as your schema grows.

When should I use compiled queries in Entity Framework Core?

Use compiled queries in EF Core for frequently repeated query shapes on hot paths. `EF.CompileAsyncQuery` pre-compiles the LINQ query, reducing query translation overhead and improving read performance.

How do I safely apply Entity Framework Core migrations to production databases?

Safely apply EF Core migrations to production by treating them as code, reviewing them explicitly, and generating idempotent SQL scripts for deployment. Avoid direct context migration in production environments.

Can I use SaveChangesInterceptor for soft deletes and auditing in EF Core?

Yes, you can use `SaveChangesInterceptor` in EF Core to handle soft deletes and audit logging. It intercepts save operations to apply cross-cutting concerns like global query filters for multi-tenancy automatically.