efcore-patterns

Provides Entity Framework Core best practices for .NET development, including NoTracking defaults and ExecuteUpdate/ExecuteDelete optimizations.

1|Updated Feb 16, 2026
One-click install
npx skills add https://github.com/bbsbot/mac-md-win --skill efcore-patterns-bbsbot
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: efcore-patterns
Source: https://github.com/bbsbot/mac-md-win/tree/main/.claude/skills/dotnet/skills/efcore-patterns
Command: npx skills add https://github.com/bbsbot/mac-md-win --skill efcore-patterns-bbsbot

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses common challenges and best practices in using Entity Framework Core, ensuring efficient, maintainable, and robust data access in .NET applications.

Core Features & Use Cases

  • Optimized Queries: Learn to use NoTracking and ExecuteUpdate/Delete for performance.
  • Migration Management: Understand safe and effective ways to manage database schema changes.
  • Reliable Data Access: Implement strategies for handling transient failures and efficient data loading.
  • Use Case: When setting up a new .NET project, use this Skill to configure your DbContext for optimal performance and learn how to safely manage database migrations throughout the development lifecycle.

Quick Start

Configure your DbContext to use QueryTrackingBehavior.NoTracking by default.

Frequently Asked Questions about efcore-patterns

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

FAQPage Schema
How do I optimize EF Core query performance in .NET?

EF Core query performance is optimized by configuring QueryTrackingBehavior.NoTracking by default, addressing N+1 problems, and using efficient bulk operations like ExecuteUpdate and ExecuteDelete to minimize database roundtrips.

What's the best way to manage EF Core database migrations?

The best approach for EF Core database migrations is avoiding manual migrations at runtime, instead using dedicated migration services potentially integrated with Aspire for safe and effective database schema changes throughout the lifecycle.

How does DbContext lifetime management work in dependency injection?

DbContext lifetime management in dependency injection requires proper configuration to prevent tracking conflicts, ensuring reliable data access and maintaining optimal performance for your .NET applications.

Why does EF Core throw tracking conflicts and how do I fix them?

Tracking conflicts in EF Core occur when multiple DbContext instances track the same entity. Fix them by setting NoTracking as the default behavior and properly managing DbContext lifetime within your dependency injection container.

Can I use execution strategies for retrying transient failures in EF Core?

Yes, execution strategies in EF Core enable automatic retries for transient failures, providing reliable data access by handling temporary connection issues and command execution failures robustly.

When do I need ExecuteUpdate and ExecuteDelete for bulk operations?

ExecuteUpdate and ExecuteDelete are needed for bulk operations when you must modify or remove large datasets efficiently without loading entities into memory, bypassing the tracking system for high-performance bulk writes.