
efcore-patterns
Entity Framework Core best practices including NoTracking by default
by aarononthewebFree
Description
NET projects. NET Aspire, and debugging change tracking problems. Its core principles start with NoTracking by default, because most queries are read-only, so tracking is something you opt in to. Migrations should never be edited by hand: the skill says to always use the CLI commands. It recommends a dedicated migration service, so that running migrations is separate from application startup. For transient database failures, it recommends an ExecutionStrategy so that operations are retried. When you use NoTracking, you explicitly mark entities for update before saving, because the context is not tracking their changes. The skill also covers loading several navigation collections efficiently with query splitting. It is part of the dotnet-skills collection by aaronontheweb. 6K installs, and its security audits all pass.…
Highlights
- NoTracking by default for read-only queries
- Query splitting for navigation collections
- Migration management and a dedicated migration service
- ExecutionStrategy for transient retries
- Guidance for .NET Aspire integration
Ratings & Reviews
No ratings yet
Be the first to rate efcore-patterns.
People also visit
efcore-patterns FAQ
When should I use it?
When setting up EF Core in a new project, optimising queries, managing migrations, integrating with .NET Aspire, or debugging change tracking.
What is the NoTracking default?
Most queries are read-only, so the skill recommends NoTracking and opting in to tracking when you need to change entities.
How should I handle migrations?
Never edit migration files by hand. Use the CLI commands, and run migrations from a dedicated migration service rather than at application startup.
How do I save changes when using NoTracking?
Explicitly mark the entities for update before saving, since the context is not tracking them.
What does query splitting solve?
Loading several navigation collections efficiently, instead of one large query.
What are the best efcore-patterns alternatives?
Popular alternatives to efcore-patterns include ef-core, ef-core and migrate. See all efcore-patterns alternatives












