我有以下实体:
Introducing FOREIGN KEY constraint 'FK_Departments_Departments_HeadDepartmentId' on table 'Departments' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
Could not create constraint or index. See previous errors.
我添加了迁移,然后尝试更新数据库,结果是:
builder.Entity<Department>()
.HasOne(p => p.HeadDepartment)
.WithMany(p => p.ChildDepartments)
.HasForeignKey(p => p.HeadDepartmentId).OnDelete(DeleteBehavior.ClientSetNull);
我再试一次:
ServerManager
但这没有帮助。