You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove migration often corrupts the model snapshot in team environments #23911
I tried to see if this was reported but could not find an issue. I hope it's not a duplicate.
EF Core version: 5.0.2 (Think it's on all)
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 3.1)
Operating system: Windows
IDE: (VS2019 , latest version)
The problem
Remove migration sometimes (quite often) corrupts the ModelSnapshot by removing too much from the snapshot. This happens when two developers create migrations in parallel and then merge these back to the development branch and someone then creates a new migration and try to revert the new one.
EF will then apply the migration snapshot from the latest of the two parallel migrations BUT it should use the merged version of these because none of the parallel migrations contains the changes from the other one in it's migration snapshot.
The issue is then that the next migrations that's added will contain more changes than it should, and most likely break when it's applied to the database.
More specifically the issue is that you can first get this when adding a migration
and then when removing the same migrations right after you can get this which obviously removes things from the snapshot that was not added by this migration.
And then when adding another new migration after that you will get this operation that tries to add the Text column to the database again.
changed the title [-]Remove migration often creates a corrupted model snapshot in team environments [/-][+]Remove migration often create a corrupted model snapshot in team environments [/+]on Jan 18, 2021
changed the title [-]Remove migration often create a corrupted model snapshot in team environments [/-][+]Remove migration often corrupts the model snapshot in team environments [/+]on Jan 18, 2021
Activity
[-]Remove migration [/-][+]Remove migration often creates a corrupted model snapshot in team environments [/+][-]Remove migration often creates a corrupted model snapshot in team environments [/-][+]Remove migration often create a corrupted model snapshot in team environments [/+][-]Remove migration often create a corrupted model snapshot in team environments [/-][+]Remove migration often corrupts the model snapshot in team environments [/+]ajcvickers commentedon Jan 19, 2021
/cc @bricelam
bricelam commentedon Jan 19, 2021
Duplicate of #8880
I hope to address situations like this (possibly just with warning) as part of #2174