Skip to content

Incorrect syntax in the script generated by command "migrations script --idempotent" #10726

Closed as not planned

Description

Hello,

I have a project with multiple migrations.
One of the migration have multiple procedures like this :
private static string SCRIPT_TableUserSynchronizationRepository_GetFirstPendingUserSynchronizations = @"CREATE PROCEDURE procedure_GetFirstPendingUserSynchronizations [...] END";

When i execute the command line "dotnet ef migrations script" everything work fine !

But when i execute the code generated by the command "dotnet ef migrations script --idempotent" i have several errors !

EF generate this kind of code :
IF NOT EXISTS(SELECT * FROM [__EFMigrationsHistory] WHERE [MigrationId] = N'20171124083142_addStoredProcedures') BEGIN CREATE PROCEDURE procedure_GetFirstPendingUserSynchronizations [...] END END; GO

And the error is "Incorrect syntax near the keyword 'Procedure'".

I have found a workaround by putting the "CREATE PROCEDURE" in "EXE(' [...]').
https://stackoverflow.com/questions/16729520/incorrect-syntax-near-the-keyword-procedure.

I use SQL Server 2016 (localdb)

Is it an EF Core bug ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions