我在C#中有以下代码:
context.Database.ExecuteSqlCommand(webpages_UsersInRolesScripts.dropConstraints);
和
public const string dropConstraints =
@"
USE [DBA];
SET ANSI_NULLS ON
DROP CONSTRAINT [webpages_Roles_UserProfiles_Target];
DROP CONSTRAINT [webpages_Roles_UserProfiles_Source];
";
这给我一条错误信息:
Message=Incorrect syntax near the keyword 'CONSTRAINT'.
答案 0 :(得分:3)
我认为您需要发出如下声明:
ALTER TABLE table_identifier DROP CONSTRAINT constraint_identifier;