This covers the pragmatic patterns you need for EF Core in production apps. It defaults to NoTracking for read queries (with clear examples of when you need to explicitly call Update()), enforces never manually editing migration files, and sets up a dedicated migration service that runs before your main app starts. The query splitting guidance helps when you're loading multiple navigation collections and hitting cartesian explosion problems. Honestly, the NoTracking-by-default approach is opinionated but makes sense for read-heavy workloads, just be ready to explicitly mark entities for updates or use AsTracking() when you actually need change detection.

skills.sh installs
1.6K
GitHub stars
1.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add aaronontheweb/dotnet-skills --skill efcore-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Entity Framework Core Patterns

When to Use This Skill

Use this skill when:

  • Setting up EF Core in a new project
  • Optimizing query performance
  • Managing database migrations
  • Integrating EF Core with .NET Aspire
  • Debugging change tracking issues
  • Loading multiple navigation collections efficiently (query splitting)

Core Principles

  1. NoTracking by Default - Most queries are read-only; opt-in to tracking
  2. Never Edit Migrations Manually - Always use CLI commands
  3. Dedicated Migration Service - Separate migration execution from application startup
  4. ExecutionStrategy for Retries - Handle transient database failures
  5. Explicit Updates - When NoTracking, explicitly mark entities for update

Pattern 1: NoTracking by Default

Configure your DbContext to disable change tracking by default. This improves performance for read-heavy workloads.

Sponsors

Details

Repository
github.com/aaronontheweb/dotnet-skills
Category
.NET & C#

More from aaronontheweb/dotnet-skills

All 34

Recommended

More .NET & C#
1aaronontheweb avatarplaywright-blazor-testingaaronontheweb/dotnet-skillsWrite UI tests for Blazor applications (Server or WebAssembly) using Playwright. Covers navigation, interaction, authentication, selectors, and common Blazor-sp560skills.sh installs
2github avataraspnet-minimal-api-openapigithub/awesome-copilotCreate ASP.NET Minimal API endpoints with proper OpenAPI documentation9.2Kskills.sh installs
3github avatarcsharp-mcp-server-generatorgithub/awesome-copilotGenerate a complete MCP server project in C# with tools, prompts, and proper configuration8.4Kskills.sh installs
4affaan-m avatarfsharp-testingaffaan-m/eccF# testing patterns with xUnit, FsUnit, Unquote, FsCheck property-based testing, integration tests, and test organization best practices.5.3Kskills.sh installs
5jeffallan avatardotnet-core-expertjeffallan/claude-skillsUse when building .NET 8 applications with minimal APIs, clean architecture, or cloud-native microservices. Invoke for Entity Framework Core, CQRS with MediatR,5Kskills.sh installs
6mindrally avataraspnet-coremindrally/skillsGuidelines for ASP.NET Core web development covering API design, authentication, caching, and best practices802skills.sh installs