-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate inside a Transaction throws InvalidOperationException #12325
Comments
Note for triage: was able to reproduce this. Logs:
|
Hello, since .net Core 2.2 will be released in Q4 2018, is there a temporary fix or workaround to use migrations inside transactions? |
@MarkusBrgr If you call |
As a workaround, you could use manual way to run migrations: |
We are using .Net Core 2.2, mysql DB with pomelo.efcore.mysql library to access it My latest migration that failed was pretty simple, 3 type change on column, 3 index added and 2 FK added. I am using it to try to make the migration run inside a transaction because, it is a huge issue for us. With this one, the DB end up with the 3 column updates and the new index but no FKs |
We are also facing this issue. The migrations is failing on creation of 10'th table leaves first 9 created. Next time when the migrations is fixed it crashes because some tables already exist |
Related to #7681 |
Triage: We should allow this unless |
btw. I've run into this today aswell, since I wanted to combine Marten and EFCore by using transaction to migrate code over to marten. first I created a transaction that adds columns to the database
I think it would be great if that would be possible. |
Same here +1 |
Also running into this issue. My case is schema-based multi tenancy. Are there any workarounds to run migrations in an existing transaction? |
Any workarounds on this one? |
At least for MySQL users: I think I found the issue, MySQL (as of version 8) does not support rolling back DDL: |
As far as I can see in v8.0.2, no transaction is created for SQL server. If you throw something in the second migration you see that the first migration got applied. I have found that |
I am trying to use context.Database.Migrate() inside a Transaction, to rollback if anything fails. As seen in the issue #6322
Here is the code i have tried to execute in the Startup:
When Executing this, it throws an InvalidOperationException:
When trying to get the transaction like this there is no transaction:
Even setting the AutoTransactionEnabled to false won`t do the trick.
Further technical details
EF Core version: 2.0.3
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 7
IDE: Visual Studio 2017 15.7
The text was updated successfully, but these errors were encountered: