I have a .NET Framework 4.8 project with using Entity Framework 6.2.0 with many migrations. My problem is, when I remove my database from my local computer and run Update-Database
the database is created successfully, but when I run Update-Database -Script
command and save my SQL script and then run the SQL script with
Invoke-Sqlcmd -InputFile ".\build\artifacts\migration.sql" -ServerInstance "(localdb)\MSSQLLocalDB"
I get many syntax errors, such as
Invoke-Sqlcmd : 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
A RETURN statement with a return value cannot be used in this context.
Why do I get these errors? And how can I resolve them? Why does a normal update-database
work correctly, but the SQL script has syntax errors?
I think adding 'GO' statements to Entity Framework migrations with some modification can resolve my problem.