CREATE DATABASE in a migration
See original GitHub issueWill appreciate the help with the next issue-
I’m working with .Net and trying to run the next migration (on MSBuild mode):
EXEC sp_executesql N'CREATE DATABASE evolveshared'
At the end of the build I’m getting the next error: ‘EvolveException: Error executing script: V01__evolveSharedCreateDataBase.sql. CREATE DATABASE statement not allowed within multi-statement transaction. Sql query: EXEC sp_executesql N’CREATE DATABASE evolveshared’ CREATE DATABASE statement not allowed within multi-statement transaction.’
When I run the same migration on SQL Management Tool (2017) it works fine and creating the asked DB.
When I’m changing the migration to the next one:
COMMIT TRAN; GO EXEC sp_executesql N'CREATE DATABASE evolveshared'
The DB is created but I’m getting a different error:
‘EvolveException: Error executing script: V01__evolveSharedCreateDataBase.sql. This SqlTransaction has completed; it is no longer usable.’
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Addressed by #150
Evolve 2.4.0 will support SQL statements like
CREATE DATABASE
in special migrations that execute outside of a transaction. To use this feature add this comment in the first line of your migration script:evolve-tx-off
.Did you figure this out? Getting the same issue.