Skip to content

Document recording the latest migration id in the model snapshot#5270

Open
roji wants to merge 1 commit intodotnet:preview-3from
roji:RecordLastestMigrationId
Open

Document recording the latest migration id in the model snapshot#5270
roji wants to merge 1 commit intodotnet:preview-3from
roji:RecordLastestMigrationId

Conversation

@roji
Copy link
Member

@roji roji commented Feb 18, 2026

@AndriySvyryd AndriySvyryd removed their assignment Feb 20, 2026

When working with Migrations in team environments, pay extra attention to the model snapshot file. This file can tell you if your teammate's migration merges cleanly with yours or if you need to resolve a conflict by re-creating your
migration before sharing it.
When working with Migrations in team environments, problems can arise when when migrations are added by multiple developers around the same time; recall that migrations aren't simply SQL scripts, but also include a snapshot of the model at the time of that migration. Possible issues include:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When working with Migrations in team environments, problems can arise when when migrations are added by multiple developers around the same time; recall that migrations aren't simply SQL scripts, but also include a snapshot of the model at the time of that migration. Possible issues include:
When working with Migrations in team environments, problems can arise when migrations are added by multiple developers around the same time; note that migrations aren't simply SQL scripts but also include a snapshot of the model at the time of that migration. Possible issues include:

When working with Migrations in team environments, problems can arise when when migrations are added by multiple developers around the same time; recall that migrations aren't simply SQL scripts, but also include a snapshot of the model at the time of that migration. Possible issues include:

## Merging
1. Developer A renames some table to X, while developer B renames the same table to Y.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed, the second point pretty much encompasses all issues

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request documents a new EF Core 11 feature that records the latest migration ID in the model snapshot, helping teams detect diverged migration trees when working on separate branches. The documentation addresses issue #37688 by explaining how this feature helps prevent merge conflicts and provides guidance on resolving them.

Changes:

  • Added documentation for the new "Latest migration ID recorded in model snapshot" feature in the EF Core 11.0 what's new page
  • Significantly revised the "Migrations in Team Environments" guide to focus on detecting and resolving diverged migration trees
  • Removed detailed merge conflict examples in favor of clearer guidance on the new automatic conflict detection mechanism

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md Added new section documenting the migration snapshot feature under the Migrations section, with cross-reference to the team environments documentation
entity-framework/core/managing-schemas/migrations/teams.md Completely restructured to focus on the new diverged migration tree detection feature, updated date, simplified resolution steps, and added preview notice
Comments suppressed due to low confidence (2)

entity-framework/core/managing-schemas/migrations/teams.md:10

  • There is a repeated word "when" in the sentence. It should read "When working with Migrations in team environments, problems can arise when migrations are added by multiple developers" (removing the duplicate "when").
When working with Migrations in team environments, problems can arise when when migrations are added by multiple developers around the same time; recall that migrations aren't simply SQL scripts, but also include a snapshot of the model at the time of that migration. Possible issues include:

entity-framework/core/managing-schemas/migrations/teams.md:22

  • The product name is inconsistent here. Line 20 uses "EF Core 11" in the NOTE block, but line 22 uses "EF 11". Based on the codebase convention (see entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md:182, entity-framework/core/providers/cosmos/saving.md:17, entity-framework/core/providers/cosmos/saving.md:21), the full "EF Core 11" should be used at the start of a sentence or when first introducing the feature, while "EF 11" is acceptable in subsequent references. However, since line 22 is the first mention in this section's body text (after the NOTE), it should use "EF Core 11" for consistency.
Starting with EF 11, the model snapshot records the ID of the latest migration. This means that if two developers each create a migration on separate branches, merging those branches will produce a source control conflict in the model snapshot file — since both branches modify the latest migration ID. This conflict is an important signal: it tells you that the migration trees have diverged, and one of them must be discarded before proceeding.

2. Developer A and B both create work branches at the same time, and generate a migration in their branches. If developer A merges their branch and then developer B does the same, the latest migration (developer B's) will have a context snapshot that does not include the changes from developer A's migration.

When you merge migrations from your teammates, you may get conflicts in your model snapshot file. If both changes are unrelated, the merge is trivial and the two migrations can coexist. For example, you may get a merge conflict in the customer entity type configuration that looks like this:
As a result, it is highly recommended to coordinate in advance and to avoid working concurrently on migrations in multiple branches.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
As a result, it is highly recommended to coordinate in advance and to avoid working concurrently on migrations in multiple branches.
As a result, it is highly recommended to coordinate in advance and to avoid working concurrently on migrations in multiple branches when possible.

Since both of these properties need to exist in the final model, complete the merge by adding both properties. In many
cases, your version control system may automatically merge such changes for you.
> [!NOTE]
> This feature is being introduced in EF Core 11, which is currently in preview.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> This feature is being introduced in EF Core 11, which is currently in preview.
> This feature is being introduced in EF Core 11 from preview-3 onwards.

the column to *Alias*, thereafter your migration renames it to *Username*.

Your migration can safely be shared with the rest of the team.
After doing this, your later migration is cleanly based on top of any migrations that have been added in the meantime, and its context snapshot contains all previous changes. Your migration can safely be shared with the rest of the team.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After doing this, your later migration is cleanly based on top of any migrations that have been added in the meantime, and its context snapshot contains all previous changes. Your migration can safely be shared with the rest of the team.
After doing this, your migration is cleanly based on top of any migrations that have been added in the other branch, and its context snapshot contains all previous changes. Your migration can now be safely shared with the rest of the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments