efcore-patterns

Optimize Entity Framework Core usage with NoTracking, query splitting, and migration workflows.

Updated Mar 14, 2026
One-click install
npx skills add https://github.com/akoken/one-piece --skill efcore-patterns-akoken
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: efcore-patterns
Source: https://github.com/akoken/one-piece/tree/main/skills/efcore-patterns
Command: npx skills add https://github.com/akoken/one-piece --skill efcore-patterns-akoken

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

EF Core projects can suffer from performance pitfalls, brittle migrations, and maintenance overhead; this Skill consolidates best practices to optimize read/write paths, manage migrations, and safely evolve data models.

Core Features & Use Cases

  • NoTracking by default to improve read performance with explicit tracking for updates
  • Explicit migration management via dedicated services and CLI guidance
  • Query splitting to load multiple collections efficiently and avoid cartesian explosion
  • Resilient execution strategies for transient failures
  • Bulk operations with ExecuteUpdate/ExecuteDelete for scalable updates

Quick Start

Apply these patterns to a real-world domain model to configure NoTracking defaults, implement split queries, and set up a dedicated migration runner.

Frequently Asked Questions about efcore-patterns

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

FAQPage Schema
How do I improve EF Core read performance for queries that don't modify data?

Improve EF Core read performance by configuring NoTracking as the default behavior, which disables change tracking for queries unless explicitly required for updates. This reduces memory overhead and speeds up data retrieval.

What is the best way to avoid cartesian explosion when loading multiple collections in Entity Framework Core?

Avoid cartesian explosion in Entity Framework Core by enabling query splitting behavior. This approach loads multiple collections in separate SQL queries rather than joining them, preventing massive intermediate result sets and boosting performance.

How do I safely run scalable bulk updates in EF Core without loading entities into memory?

Run scalable bulk updates in EF Core using ExecuteUpdate and ExecuteDelete operations. These methods execute directly against the database to modify or delete records without loading entities into the change tracker, ensuring high performance.

How do I manage EF Core migrations to prevent brittle database schema updates?

Manage EF Core migrations safely through dedicated services and CLI workflows. Establishing a dedicated migration runner separates migration execution from application startup, preventing schema drift and ensuring reliable database evolution.

Why does my Entity Framework Core application fail during transient database connection drops?

Entity Framework Core applications fail during transient connection drops if they lack resilient execution strategies. Implementing a retry policy handles these temporary failures automatically, stabilizing data access operations.

Can I use EF Core query splitting with existing domain models?

Yes, you can apply EF Core query splitting to existing domain models. Configuring this behavior optimizes read paths by loading multiple collections efficiently, directly addressing performance degradation without altering the underlying data structure.