File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Provider/src/EntityFramework.Firebird Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -55,9 +55,19 @@ public override IEnumerable<MigrationStatement> Generate(IEnumerable<MigrationOp
5555 var updateDatabaseOperation = lastOperation as UpdateDatabaseOperation ;
5656 var historyOperation = updateDatabaseOperation != null
5757 ? updateDatabaseOperation . Migrations . First ( ) . Operations . OfType < HistoryOperation > ( ) . First ( )
58- : ( HistoryOperation ) lastOperation ;
59- var modify = historyOperation . CommandTrees . First ( ) ;
60- _migrationsHistoryTableName = ( modify . Target . Expression as DbScanExpression ) . Target . Table ;
58+ : lastOperation as HistoryOperation ;
59+
60+ if ( historyOperation != null )
61+ {
62+ var modify = historyOperation . CommandTrees . First ( ) ;
63+ _migrationsHistoryTableName = ( ( DbScanExpression ) modify . Target . Expression ) . Target . Table ;
64+ }
65+ //This happens only and only if downgrading database to initial point (ie. reverting also Initial migration)
66+ else
67+ {
68+ var dropTableOperation = ( DropTableOperation ) lastOperation ; //DropTableOperation for MigrationHistory-table
69+ _migrationsHistoryTableName = Regex . Replace ( dropTableOperation . Name , @".+\.(.+)" , "$1" ) ;
70+ }
6171
6272 return GenerateStatements ( migrationOperations ) . ToArray ( ) ;
6373 }
You can’t perform that action at this time.
0 commit comments