dotnet / EntityFramework.Docs

Documentation for Entity Framework Core and Entity Framework 6
https://docs.microsoft.com/ef/
Creative Commons Attribution 4.0 International
1.63k stars 1.96k forks source link

How do EF Migrations work with Git Reverts #3560

Open kevingates opened 3 years ago

kevingates commented 3 years ago

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.

ajcvickers commented 3 years ago

@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.

GC-BenLeeHughes commented 3 years ago

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.