Note that there are some explanatory texts on larger screens.

plurals
  1. POEntity Framework Migrations - Managing In Branches
    text
    copied!<p>I've been using Entity Framework code first migrations for a while now on a brand new project, and they've been working fine so far on a the main trunk version of the application.</p> <p>However, we're now at a point in the project where branches are being created as we have multiple workstreams going on. As part of the last lot of work, we realised that using migrations across branches can be problematic - so my question is what have people found the best way of managing this?</p> <p>For example (I've obviously simplified these for the sake of discussion):</p> <p>Branch A: Developer 1 adds an 'Add-UserDateCreated' migration which adds a field to the User entity. The migration file contains the code to add the field, and has the model state at the time.</p> <p>Branch B: Developer 2 adds an 'Add-UserMiddleName' migration which adds another field to the User entity. The migration file contains the code to add the field, and the has the model state at the time (but it obviously DOESN'T have the field added in the other migration).</p> <p>These migrations work fine on their branches, but when you merge them back into the trunk, you get stuck:</p> <ul> <li>You can't just keep the individual migration files as the stored model state won't be correct. For example, the 'Add-UserMiddleName' migration SHOULD have the state of the model with the 'Add-UserDateCreated' field added - but it won't.</li> <li>You can't merge the migrations into one file as you hit the same issue*</li> </ul> <p>Which means the only way to truely avoid these issues is to work on a different copy of the database for each branch, ignore the migrations when you do the merge into the trunk, and add a one shot master migration when the merge is complete (on the trunk version of the database) - but then you potentially end up with lots of changes in one migration which is never a good idea (and also lose any custom code you've written in your migration class).</p> <p>So how do other people manage these kind of situations? I'd be curious to know other peoples' opinions.</p> <p>*I'm curious what issues this would actually cause in the real world, if anyone knows?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload