GO statements are placed incorrectly when generating migration scripts
kenthie42 opened this issue · comments
I have a migration which references a SQL file containing
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE ...
Generating a script from the previous migration to this one produces SQL that begins:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
CREATE PROCEDURE ...
This script is invalid, because CREATE PROCEDURE
has to be the only statement in its batch.
To give another example, if I add a migration with SQL
CREATE TABLE [Table1] ([Column1] int);
ALTER TABLE [Table1] ADD [Column2] int;
GO
ALTER TABLE [Table1] ADD [Column3] int;
GO
INSERT INTO [Table1] ([Column1], [Column2], [Column3]) VALUES (1, 1, 1);
the generated script is
CREATE TABLE [Table1] ([Column1] int);
ALTER TABLE [Table1] ADD [Column2] int;
GO
ALTER TABLE [Table1] ADD [Column3] int;
INSERT INTO [Table1] ([Column1], [Column2], [Column3]) VALUES (1, 1, 1);
INSERT [dbo].[__MigrationHistory]...
This script also won't run, because of the missing GO
before the second ALTER TABLE
.
I think the GO
statements are being placed above the statements rather than below them here:
Further technical details
EF version: 6.4.4
Database Provider: SqlServer
Operating system: Windows 10
IDE: Visual Studio 2019 Version 16.11.9
This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.