Cascade deleting one-to-one linked entities
Posted: Tue 02 Oct 2018 04:09
Hello.
Using Delphi XE5 and EntityDAC 2.0.1.
I have two entities linked one-to-one:
Project( Id, Name, ... ) and ProjectSchedule ( Id, ProjectId, ... );
In general schedule's fields may be easily inluded in Project table but I separated it for further possible needs. So, in Entity Developer I linked them as one-to-one relationship with Cascade=True and Delete_Rule=Cascade. Ok. But when I try
I get and DB exception: FK violated. Child record found.
But if I change relationship to one-to-many the same works fine. But in this case access to schedule looks like
which is really terrible.
How to cascade delete one-to-one related entities?
Using Delphi XE5 and EntityDAC 2.0.1.
I have two entities linked one-to-one:
Project( Id, Name, ... ) and ProjectSchedule ( Id, ProjectId, ... );
In general schedule's fields may be easily inluded in Project table but I separated it for further possible needs. So, in Entity Developer I linked them as one-to-one relationship with Cascade=True and Delete_Rule=Cascade. Ok. But when I try
Code: Select all
project.DeleteAndSave( True );
But if I change relationship to one-to-many the same works fine. But in this case access to schedule looks like
Code: Select all
project.ProjectShedules.First
How to cascade delete one-to-one related entities?