0

I have an ASP.NET MVC 5.2.3.0 project that uses Entity Framework 6 with the code-first approach and an Oracle Database using ODAC.

I use EF Migrations to keep the database up-to-date however I encounter a problematic that I do not know to solve.

In my team we have created a TFS branch called "Version2.00" that was tested internally by our project team.

This branch "Version2.00" continues to evolve to bug fixes and some small changes requested by ours clients.

In parallel we have the initial branch called "InProgress" which continues to evolve with major changes.

My question is simple: on customer database how to update database to go on a futur branch ("Version2.1" for example) from 'Version2.00' database ? (see the picture for more informations)

I need your help. Thanks.

EF Migration branches problem

Vincenzo
  • 1,741
  • 2
  • 16
  • 26
  • Yes the code first migrations can only cope with linear progression and it's a real problem when working with branches. It's easy enough to see why - it wouldn't know how to resolve conflicts. We ended up having to merge whenever a new migration was added which wasn't ideal. – PeteG Dec 22 '15 at 11:17
  • Or http://stackoverflow.com/q/24685958/861716 – Gert Arnold Dec 22 '15 at 15:39

1 Answers1

0

This bites so many teams, it's ridiculous. The solution? Don't commit migrations. Migrations are personal, unique to each developer and their individual development database.

Instead, when developers pull down modified classes, they will each be individually prompted to migrate their development database when they try to navigate to a URL in their local instance of the website.

Before deploying, pull down the code to a clean environment, specific to deployment and either generate a migration there or otherwise evaluate what database changes need to be made to the production database. Then deploy those schema changes following proper change management.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444