2

I have a feature branch I have been working on some database changes which resulted in one migration. Meanwhile, my college has merged a migration of his own into master.

The problem occurs when I try to merge master containing his migration into my feature branch to resolve conflicts. I have to resolve two conflicts in the .csproj file choosing which migration to keep. I want to keep both.

I perform the merge in Visual Studio 2019. Before the merge, I can run EF commands just fine on my feature branch, but after the merge, I get this error message:

Unable to update the database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.

I have searched for an answer but found nothing that applies to my problem. I can not run Update-Database because our pipeline runs all the EF migrations.

Does anybody know why EF is throwing this error?

Entity Framework Core .NET Command-line Tools: 6.0.3

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
AllramEst
  • 1,319
  • 4
  • 23
  • 47
  • 1
    Merging migrations between branches will often require manual intervention. The issue is that your migrations are A -> B, the other merged changes went from A -> C, so after you merge down from Trunk which is now C, your migrations won't work as they weren't set up for C -> B. This link should give you some ideas on how to handle it a couple different ways: https://stackoverflow.com/questions/10556348/how-to-manage-migrations-in-a-project-with-multiple-branches – Steve Py Apr 12 '22 at 12:30
  • You saved my bacon. That work effortlessly. make it a suggestion and I will mark it as the solution. – AllramEst Apr 12 '22 at 13:36
  • 1
    All good, just upvote the answer from the link which helped you out. :) – Steve Py Apr 13 '22 at 02:40

0 Answers0