SqlException: Syntax Error Near 'GO'

前端 未结 3 941
無奈伤痛
無奈伤痛 2021-01-17 11:06

I am having trouble sending a SQL statement through a DbContext using context.Database.ExecuteSqlCommand().

I am trying to execute

CREA         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 11:59

    GO is not a part of SQL, so it can't be executed with ExecuteSqlCommand(). Think of GO as a way to separate batches when using Management Studio or the command-line tools. Instead, just remove the GO statements and you should be fine. If you run into errors because you need to run your commands in separate batches, just call ExecuteSqlCommand() once for each batch you want to run.

提交回复
热议问题