1

在 Sql Server 2012 中,我有一个员工表。如下

 table {id, managerId, name}

并且该表在 ManagerId 和 Id 之间有一个外键。

我想删除所有人“约翰”。

问题是我得到一个外键异常(使用 ef 和级联删除)。如何使用自引用外键从表中删除行。

4

1 回答 1

1

OK suppose you have a manager named John. You can't delete him because you have related records for his employees.

Your first step is to update the employee records for managers you intend to delete to either have no manager or move them to a new manager. Then you can delete managers who are named John.

于 2013-10-16T15:07:23.793 回答