Entity Framework - how to create sql script with “GO” statements

后端 未结 2 1866
生来不讨喜
生来不讨喜 2020-12-18 14:29

In EF 6.1 you can run the command:

update-database -script

This generates the full SQL script for one or many migrations. The problem we f

2条回答
  •  有刺的猬
    2020-12-18 15:04

    If you are trying to alter a view using Sql('Alter View dbo.Foos As etc'), then you can avoid the

    should be the first statement in a batch file error

    without adding GO statements by putting the sql inside an EXEC command:

    Sql(EXEC('Alter View dbo.Foos As etc'))
    

    Reference:

    https://stackoverflow.com/a/20352867/150342

提交回复
热议问题