2016-08-14 9 views
0

I持って、次のscenario-私は3つの新しいマイグレーションを追加した支店で働いていますマージ複数回の移行Entity Frameworkのコードファースト

- しようとしたとき、私は彼ら

Migration A 
Migration B 
Migration C 

に名前を付けるだろう大会のためにmasterとマージすると、時間順に並べられていない4つの新しいマイグレーションがあることが分かります(別のブランチからマージされています)。追加するとき - 私は何を意味することは、次の

new Migration from master 1 
existing Migration in both branches 
existing Migration in both branches 
new Migration from master 2 
new Migration from master 3 
new Migration from master 4 
existing Migration in both branches 
existing Migration in both branches 

そして、私が今明らかにEntity Frameworkのは、それはモデルが間違っていると考えているので、私はデータベースを更新させません、次のシナリオ

new Migration from master 1 
existing Migration in both branches 
existing Migration in both branches 
new Migration from master 2 
new Migration from master 3 
new Migration from master 4 
existing Migration in both branches 
existing Migration in both branches 
Migration A 
Migration B 
Migration C 

を得る合流です新しい移行では、前述の4つの新しい移行からの変更がmasterから生成されます。

本当の問題は、(別のquestionanswerを受け入れごとに示​​唆されているように)彼らは時系列 を発注していないので、私は、メタデータを更新するために、既存のバック移行してから再足場に戻すことはできませんということです。

私はそれを再骨格にnew Migration from master 1、その後Add-Migration <timestamp> new Migration from master 1前に戻って、移行にupdate-database -targetに試してみましたが、私はUnable to generate an explicit migration because the following explicit migrations are pending....例外を取得。

これを修正するためにブランクマイグレーションを追加するのではなく、これをクリーンで適切な方法で見つけてください。

答えて

0

さらに調査した結果、最後の移行前にデータベースを移行してから最後の移行を再構築するというソリューションがありました。

update-database -target Migration B 
add-migration <timestamp>_Migration C