efcore.pg icon indicating copy to clipboard operation
efcore.pg copied to clipboard

It is impossible to use a user transaction during the migration process

Open jabacrack opened this issue 1 year ago • 1 comments

After the latest updates in the documentation, the EF Core team clarified that user transactions can be used in manual migrations with some restrictions: https://github.com/dotnet/EntityFramework.Docs/issues/4896 https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-9.0/breaking-changes#migrations-transaction

However, the NpgsqlHistoryRepository.GetCreateIfNotExistsCommands method, which is called during each Migrator.MigrateAsync execution, sets the SuppressTransaction property to true for every SQL operation. As a result, any migration using an external transaction throws an exception: "User transaction is not supported with a TransactionSuppressed migration or a retrying execution strategy."

jabacrack avatar Jan 21 '25 11:01 jabacrack

I plan to reexamine the strategy here in #3407, will look at this at the same time.

roji avatar Jan 21 '25 14:01 roji