Ef6: "INSERT INTO MigrationHistory" added to the body of generated stored procedure

Created on 6 Jun 2017  路  2Comments  路  Source: dotnet/ef6

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

type-bug

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.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings