Skip to content

Breaking change note: migrations --output-dir now also places the model snapshot - #5511

Draft
ajcvickers wants to merge 1 commit into
dotnet:mainfrom
ajcvickers:breaking-change-migrations-snapshot-output-dir
Draft

ajcvickers wants to merge 1 commit into
dotnet:mainfrom
ajcvickers:breaking-change-migrations-snapshot-output-dir

Conversation

@ajcvickers

Copy link
Copy Markdown
Contributor

Breaking change note for dotnet/efcore#39565, which makes dotnet ef migrations add --output-dir write the model snapshot to the output directory too (tracking issue dotnet/efcore#24339). Previously the snapshot stayed beside the existing snapshot, so using a different --output-dir per batch of migrations now moves the snapshot each time.

There are no EF Core 12 docs yet (main of dotnet/efcore is 12.0, and release/11.0 has branched), so this starts the EF Core 12 breaking changes page with just this entry, like the first EF Core 11 breaking change note did. I haven't touched toc.yml, the 12.0 what's-new page, or the existing pages.

This is a draft until the efcore PR is merged. The follow-up efcore PRs (migrations remove --output-dir, dotnet/efcore#39567, and the EFMigrationsOutputDir property, dotnet/efcore#39568) are not described here since they are not breaking changes and are not merged.

🤖 Generated with Claude Code

…tput-dir

See dotnet/efcore#24339 and dotnet/efcore#39565

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new EF Core 12 breaking-changes page has an active navigation omission and two wording inaccuracies that should be corrected before publication.

3 open issues
What changed in this PR

This draft PR starts the EF Core 12 breaking-changes page. It documents one change: dotnet ef migrations add --output-dir (and Add-Migration -OutputDir) now writes the model snapshot to the output directory too. The page is meant to be published once the linked efcore PR (dotnet/efcore#39565) merges.

Changes:

  • Adds the new page with front matter, links to earlier breaking-change pages, and a summary table.
  • Adds a low-impact entry covering the old and new snapshot behavior, how an existing snapshot is moved or kept, the --dry-run behavior, the new PreviousSnapshotFile property, the reasons for the change, and mitigations for users who pass a different --output-dir for each batch.
File Description
entity-framework/​core/​what-is-new/​ef-core-12.0/​breaking-changes.md New EF Core 12 breaking-changes page that documents the snapshot now following --output-dir, with mitigations.

Review effort: Lite

@@ -0,0 +1,56 @@
---

When `--output-dir` is specified, the model snapshot is written to that directory as well, together with the migration and designer files. This applies to relative paths, to paths outside the project directory, to absolute paths, and when `--namespace` is also specified.

If the context already has a snapshot in a different file, the new snapshot is written first and the old file is then deleted, so that only one snapshot remains. The old file is deleted only when exactly one file in the project or the output directory declares the snapshot class. If there are several, or the existing snapshot can't be found, nothing is deleted and a warning is reported. If a file with the snapshot's name already exists in the output directory but declares a different class, such as the snapshot of another `DbContext`, the command fails instead of overwriting it.

- If you pass a different `--output-dir` for each batch of migrations, for example `Migrations/2025` and then `Migrations/2026`, the snapshot now moves each time. Use the same output directory for every migration, or omit `--output-dir` after the first one to keep new files beside the existing ones.
- The snapshot's path changes when it moves. Make sure the new path is committed and, if your project lists compile items explicitly, included in the project. The Package Manager Console updates these project items for you.
- If the snapshot is outside the project directory, pass the same `--output-dir` to every `migrations add` command. Otherwise EF can't find the existing snapshot, warns, and writes a second one inside the project.
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