Skip to content

How do EF Migrations work with Git Reverts #3560

Closed

Description

@kevingates

I understand you can make migrations with Entity Framework (Core). However, what isn't clear is what happens if someone reverts in GitHub the changes.

So here is scenario 1:

  1. Makes a DB change 1.
  2. Make Commit-1 for DB1 to GitHub.
  3. Make a DB change 2.
  4. Make Commit-2 for DB2 to Github.
  5. Revert Commit-2 (an immediate rollback).

Now what?

So here is scenario 2:

  1. Makes a DB change 1.
  2. Make Commit-1 for DB1 to GitHub.
  3. Make a DB change 2.
  4. Make Commit-2 for DB2 to Github.
  5. Revert Commit-1 (an earlier revert).

Now what?

Summary

It's not clear what happens in term of Database EF Migrations when you have Git Reverts.

An article describing the suggested methodology would be incredibly helpful.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

  1. ajcvickers commented on Nov 16, 2021

    @ajcvickers
    Contributor

    @kevingates Generally speaking, don't remove the code for a migration without first removing the migration. That being said, as long as you're not rewriting history in the git repo, then you can always go back to the commit that contains the migration code and roll back the migration from there.

  2. GC-BenLeeHughes commented on Nov 16, 2021

    @GC-BenLeeHughes

    Thank you for your clarification. Is there a chance that we could get a direct article on the official docs for the standard process for this? There is not a lot of articles on the proper rollback strategies, even unofficial articles outside the Microsoft docs.

  3. added this to the Backlog milestone on Nov 19, 2021
  4. added a commit that references this issue on Aug 11, 2026
    bb42937
  5. modified the milestones: Backlog, 11.0.0 on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions