update-pipeline

Explain EF Core's SaveChanges update pipeline converting tracked changes into SQL commands.

14.8k|3.4k|Updated Jan 23, 2014
One-click install
npx skills add https://github.com/dotnet/efcore --skill update-pipeline
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: update-pipeline
Source: https://github.com/dotnet/efcore/tree/main/.agents/skills/update-pipeline
Command: npx skills add https://github.com/dotnet/efcore --skill update-pipeline

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides implementation details for the EF Core SaveChanges update pipeline, describing how tracked changes are converted into database commands and the key components involved (UpdateAdapter, ModificationCommand, Batch processing, UpdateSqlGenerator, etc.)

Core Features & Use Cases

  • Flow covers converting tracked changes into INSERT/UPDATE/DELETE commands during SaveChanges.
  • Topological ordering of commands via a Multigraph to respect foreign key dependencies.
  • Grouping commands into batches with respect to max batch size and executing using a BatchExecutor in a transactional context.
  • Validation of store-generated values and handling of concurrency with DbUpdateConcurrencyException on mismatches.
  • References to key source files like src/EFCore.Relational/Update/Internal/SharedTableEntryMap.cs for deeper understanding.

Quick Start

Review the update pipeline flow and its components to understand how EF Core translates changes into SQL.

Frequently Asked Questions about update-pipeline

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

FAQPage Schema
How does EF Core SaveChanges translate tracked changes into SQL commands?

EF Core SaveChanges translates tracked changes into SQL commands by passing modifications through the Update Pipeline, which utilizes CommandBatchPreparer, UpdateSqlGenerator, and ModificationCommand components to generate and execute store-specific operations.

How does EF Core handle foreign key dependencies when batching update commands?

EF Core handles foreign key dependencies during SaveChanges by applying topological sorting via a Multigraph, ensuring that ModificationCommands are ordered correctly to respect relational constraints before batch execution.

How are store-generated values validated during the EF Core update pipeline?

Store-generated values are validated during the EF Core update pipeline through specific propagation logic within the UpdateAdapter, ensuring database-generated keys and defaults are correctly mapped back to tracked entities.

What happens when a concurrency check fails during EF Core SaveChanges?

When a concurrency check fails during EF Core SaveChanges, the update pipeline throws a DbUpdateConcurrencyException, halting the transactional BatchExecutor to signal a data mismatch between the tracked entity and the database row.

How does EF Core group modification commands into batches for database execution?

EF Core groups ModificationCommands into batches by respecting the configured maximum batch size, executing these grouped commands transactionally using a BatchExecutor to optimize database roundtrips during SaveChanges.