Skip to content
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

EF Core migrations with suppressTransaction: true fail during publish #12676

Open
bricelam opened this issue Jul 28, 2020 · 1 comment
Open
Assignees

Comments

@bricelam
Copy link
Contributor

bricelam commented Jul 28, 2020

Some SQL statements cannot run inside a transaction. EF Core allows you to suppress the transaction inside the migration:

migrationBuilder.Sql(
    "CREATE FULLTEXT CATALOG ftCatalog AS DEFAULT;",
    suppressTransaction: true);

Unfortunately, this doesn't work when applying the migration during publish via Web Deploy.

Error: CREATE FULLTEXT CATALOG statement cannot be used inside a user transaction.

In order to fix this, we need to add transacted="false" to the dbfullsql provider in the MSDeploy manifest.

<dbfullsql path="C:\Path\To\WebApplication1.Data.ApplicationDbContext.sql"
           transacted="false" />

Once we do this, the script will need to start managing transactions. This work is tracked by dotnet/efcore#7681. We may put this feature behind a flag (e.g. --use-transactions) or we may just start always including them in the script.

⚠️ Warning, we need to ensure that we don't disable transactions entirely. Projects referencing older versions of EF Core or users with older versions of dotnet ef won't be able to manage transactions inside the script, so we should never add transacted="false" to the manifest in these cases.

cc @vijayrkn @ajcvickers @JeremyLikness

@bricelam
Copy link
Contributor Author

bricelam commented Aug 7, 2020

(Following up after the implementation of dotnet/efcore#7681)

Any project referencing Microsoft.EntityFrameworkCore version 5.0.0 or higher will include SQL transaction statements (even when using older versions of dotnet ef) and can safely add transacted="false" to the manifest.

@bricelam bricelam removed the Blocked Issue is blocked on an external dependency label Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants