I am trying to use the AlterStoredProcedure function in a migration's Up method. When I use the Update-Database command, it works correctly. However, when I generate a script for updating the database manually, via the -Script switch, the generated SQL script (containing only the last migration) creates a stored procedure which inserts an entry into __MigrationHistory table on every execution.
sql
ALTER PROCEDURE ...
...
BEGIN
...
END
INSERT [dbo].[__MigrationHistory] ... VALUES ...
As a result, INSERT will be the last statement of the stored procedure. It seems like a GO statement is missing between END and INSERT.
Is there a workaround?
Version info:
EF 6.1.3
SQL Server 2016
Add the GO manually??
@ErikEJ, that's fine once, but it wouldn't be very safe to have to remember that for every stored procedure and every run of the script generation tool.
Most helpful comment
@ErikEJ, that's fine once, but it wouldn't be very safe to have to remember that for every stored procedure and every run of the script generation tool.