Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force history update on snapshot. #43

Closed
Tyroche opened this issue Aug 11, 2016 · 2 comments
Closed

Force history update on snapshot. #43

Tyroche opened this issue Aug 11, 2016 · 2 comments

Comments

@Tyroche
Copy link

Tyroche commented Aug 11, 2016

I'm currently working on a project where multiple developers are adding migrations into source control at the same time using EF6 CF. Both of the developers will make a change to their migrations, but when the second one merges in the code from the first, their migrations don't contain the correct snapshot, causing the Update-Database to fail due to pending migrations (although they are covered by the merged-in migrations).

Examples:

http://stackoverflow.com/questions/19136066/why-does-add-migration-sometimes-create-duplicate-migrations

http://stackoverflow.com/questions/17921886/update-database-fails-due-to-pending-changes-but-add-migration-creates-a-duplic

I wasn't sure if there was currently a way to fix this issue other than to create an empty migration to get a valid snapshot of the state of the system.

If there is not, I propose that a command is added that allows a developer to force-update the history tracking on the latest migration so that the Update-Database command will be better able to determine if there are really pending changes or not.

Note that this would also be a problem if you were to copy/paste a migration into your migrations folder -- so it's not necessary limited to developer teams.

@divega divega added this to the 6.2.0 milestone Aug 15, 2016
@bricelam
Copy link
Contributor

This is one of the pitfalls of using Code First Migrations in team environments. The Code First Migrations in Team Environments article will walk you through the steps needed to resolve issues like this. Have at least one person on your team get familiar with it. 😉

Don't hesitate to ask if you have any specific questions on how to apply the article to your scenario.

Also, we feel your pain. This is one area that we've worked hard to improve in EF Core. We've introduced a common model snapshot file that will make merging migrations a lot easier.

@Tyroche
Copy link
Author

Tyroche commented Aug 15, 2016

Thanks Brice!

A very informative and useful answer. I'll be sure to share the article with my team. :)

@divega divega removed this from the 6.2.0 milestone May 22, 2017
@bricelam bricelam removed their assignment May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants