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

Refrain from using transactions in migrations when targeting YugabyteDB

Open roji opened this issue 2 years ago • 8 comments

YugabyteDB doesn't (currently) support running DDL within transactions; we can add a YugabyteDB compatibility config, and refrain from using transactions.

In the meantime, a good workaround is to generate the migrations as a SQL script, and run that.

Originally raised as https://github.com/dotnet/efcore/issues/30881

/cc @FranckPachot

roji avatar May 25 '23 15:05 roji

Any update on this?

pantonis avatar Dec 09 '25 08:12 pantonis

Nope, if there were it would be posted here.

roji avatar Dec 09 '25 08:12 roji

YugabtyeDB now supports transactional DDL in tech preview: https://docs.yugabyte.com/stable/explore/transactions/transactional-ddl/

FranckPachot avatar Dec 09 '25 08:12 FranckPachot

Thanks @FranckPachot, that's great news. That's the best solution here.

roji avatar Dec 09 '25 21:12 roji

Apologies, question for update was about postgres not YugabyteDb, I came across the link for issue #30881.

pantonis avatar Dec 10 '25 05:12 pantonis

@pantonis I don't understand, what's your question exactly? Why are you trying to disable migration transactions on PostgreSQL?

roji avatar Dec 10 '25 07:12 roji

Some of the commands that we need to run cannot run inside transactions.

pantonis avatar Dec 10 '25 07:12 pantonis

Hi everyone,

We wanted to provide an official update on this request. As informed by @FranckPachot , the feature is already present in Tech preview and will work if enabled explicitly by following the steps. The feature will be enabled by default in our future release coming early next year.

You can follow the implementation progress in our public tracking issue here: https://github.com/yugabyte/yugabyte-db/issues/3109

Thank you for your patience and continued interest. We’ll share updates as we get closer to the release.

suranjan avatar Dec 12 '25 13:12 suranjan

Some of the commands that we need to run cannot run inside transactions.

@pantonis that's unrelated to this issue, which is about the provider globally not ever using transactions. EF already allows you to suppress transactions for specific operations when including custom SQL, see these docs.

As Yugabyte is introducing support for migrations, I'll go ahead and close this issue.

roji avatar Dec 12 '25 14:12 roji