When adding the SQL server GO command
to a DbMigration.Sql("GO ...")
call causing the Update-Database
entity framework method to throw the exception "argument 'sql' cannot be null".
Remove the GO
and the migration fails because the next SQL statement is creating a trigger, which must be on its own.
I found absolutely no info on this issue, so thought SO might benefit.
From reading around, I found that in SQL Server GO
must be followed by a newline, so I think the root cause to this issue has to do with that and how EF parses the SQL before sending to the DB.
The way I solved the issue was discovering an optional parameter to the DbMigration.Sql(sql, suppressTransaction=false)
method.
suppressTransaction
forces the sql query to be separate to the rest of the migration (usually this is all called as one transaction). Hence removing my need to use GO
at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With