我有两个表Application_User和Application_User_Access. Application_User_Access表与Application_User表具有外键约束.
当我删除Application_User表中的记录时,我收到“与REFERENCE约束冲突的DELETE语句”异常.
解决方法
您可以为Application_User_Access表实现级联删除.为此,您需要稍微修改数据库架构.具体删除Application_User_Access中的先前引用到Application_User表并添加一个新引用:
--not sure about the column names though ALTER TABLE Application_User_Access ADD CONSTRAINT FK_Application_User_Access_Application_User FOREIGN KEY (used_id) REFERENCES Application_User(id) ON DELETE CASCADE GO