3

I have previously used DbUp for database migrations. One of the features that I liked was that it could wrap all of the migration scripts in a single transaction. So if any of the migration scripts failed, any previously executed migration scripts would be rolled back.

Can Entity Framework 6 wrap all migrations with a single transaction?

gannawdm
  • 51
  • 5
  • What made you think EF6 does not wrap all migrations in a single transaction? – Alisson Reinaldo Silva Dec 21 '17 at 18:31
  • I've never seen any definitive documentation that they run in transactions. If you generate a script, it definitely does not. So while individual migrations may be transactional (not even sure about that see [here](https://github.com/aspnet/EntityFrameworkCore/issues/6322)), running them all in a batch may require something like [this](https://stackoverflow.com/questions/32014118/can-entity-framework-6-migrations-include-a-transaction-around-scripts). – Steve Greene Dec 21 '17 at 19:30
  • Also, this issue can be mitigated because you can rollback by changing the TargetMigration. Not something I would recommend for PROD. – Steve Greene Dec 21 '17 at 19:32
  • When you execute your migration scripts, do you wrap them in a transaction yourself? – Ciaran Gallagher Jul 26 '18 at 13:59
  • 2
    Did you ever find a solution for this. No EF core does not wrap them in transactions – Enrico Jul 13 '20 at 12:48

0 Answers0