The key is is the phrase
"multiple cascade paths". This means that deleting one entity could cause another entity to be deleted via multiple relationships.
In this case, deleting a
PMS_Company
will delete both the users and the roles in that company. Deleting the users will delete the associated
PMS_UserRole
entities. Deleting the roles will delete the associated
PMS_UserRole
entities. Therefore, there are two paths by which a single delete could cause a
PMS_UserRole
to be deleted, which SQL Server does not allow.
Error message 1785 occurs when you create a FOREIGN KEY constraint that may cause multiple cascade paths[
^]
It's an annoying limitation, but it's one you have to live with. You will have to change one or more of the relationships to not cascade on delete. When you want to delete the parent entity, you will need to manually delete the related entities instead of relying on the cascade delete behaviour.
For example:
builder.HasOne(ur => ur.Role)
.WithMany(x => x.UserRoles)
.HasForeignKey(x => x.RoleId)
.OnDelete(DeleteBehavior.None);
Cascade Delete - EF Core | Microsoft Docs[
^]