efcore-patterns

Configure EF Core NoTracking, split queries, and retry strategies for data access.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/afonsoft/VideoChat --skill efcore-patterns-afonsoft
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: efcore-patterns
Source: https://github.com/afonsoft/VideoChat/tree/main/.agents/skills/efcore-patterns
Command: npx skills add https://github.com/afonsoft/VideoChat --skill efcore-patterns-afonsoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

EF Core projects often struggle with performance, inconsistent change tracking, and complex migrations. This skill codifies best practices to optimize data access, manage migrations, and guard against common pitfalls.

Core Features & Use Cases

  • NoTracking by default to improve read performance; explicit tracking when needed
  • Never edit migrations manually; use CLI and automated migration workflows
  • Dedicated migration service to run migrations before app startup with retry strategies
  • ExecutionStrategy for transient failures with safe retry patterns
  • Bulk operations using ExecuteUpdate/ExecuteDelete to avoid loading entities
  • Query splitting to avoid cartesian explosion when loading multiple navigations
  • Proper DI lifecycle and context usage to prevent tracking conflicts

Quick Start

Configure your DbContext to disable tracking by default, enable query splitting for large navigations, and implement a dedicated migration service with retry strategies.

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 large queries?

EF Core query performance improves by using NoTracking by default to skip change tracking overhead and enabling query splitting to avoid cartesian explosion when loading multiple navigations. Apply explicit tracking only when entity modifications are needed.

What is the best way to run Entity Framework Core migrations before app startup?

The best way to handle EF Core migrations is implementing a dedicated migration service with retry strategies that executes before app startup. Never edit migrations manually; rely on CLI and automated workflows to ensure safe schema changes.

How do I prevent cartesian explosion when loading related data in EF Core?

To prevent cartesian explosion in EF Core, enable query splitting for large navigations. This separates related data into multiple SQL queries, reducing memory pressure and avoiding duplicate row data during multi-navigation loads.

Does EF Core support bulk updates and deletes without loading entities?

EF Core supports bulk updates and deletes without loading entities by using ExecuteUpdate and ExecuteDelete operations. These commands execute directly against the database, bypassing change tracking and improving performance for large dataset modifications.

How do I handle transient failures in Entity Framework Core?

Handle transient failures in EF Core by implementing an ExecutionStrategy with safe retry patterns. This automatically retries failed operations, ensuring reliability during temporary database connectivity issues or transaction deadlocks.

When should I use NoTracking in Entity Framework Core?

Use NoTracking by default in EF Core for read-only queries to improve performance by skipping change tracking. Switch to explicit tracking only when you need to modify and save entities back to the database.