Hi Friends,
I want to delete all the child records from all the related entities.
For that we have 2 Approaches :
1.Using Cascade Delete
2.Writing a C# Code using Entity Meta Data.
If i go for the first one using Cascade Delete ,Does it work in the bulk data like if the parent entity has many related child records(Lets say 50k or more).And these 50k records are from all the related entities.
If i go for the 2 one then its taking much more time than i was expecting and the logic is much more complex.
Please guide me though this scenario so that i could complete it ASAP.
Any help will be highly appreciative.
Thanks
Shashikant Saxena
*This post is locked for comments
Thanks for the reply ,this is good approach to opt
Thanks
Shashikant Saxena
Hi, I would suggest you to go with Out of box Bulk delete job to delete parent entity and it will delete all child entity records.
Another approach would be,
1) Create bulk delete jobs for different child entities separately (Need to write accurate query in job).
2) Delete these child entity records first and after these jobs finished, create Bulk delete job for parent entity.
The advantage in this approach is, while deleting Parent entity records deletion process will be quick as you have already cleared most of the child records. Test thoroughly this approach before implementation.
Thanks,
Anand
As long as there is a proper parent child relationship and the behaviour is configured for cascade delete the system will delete all the child records.
You could create bulk delete job with a selected few records in the filter and see if it does what you want to.
Once its confirmed you can then expand your bulk delete system job query to pickup all the records you intend to delete.
In your test if it does not delete as you wanted to then we will have to consider other options.
I would go for out of the box bulk delete first as that does not require any extra effort.
Please remember that the bulk delete job runs async and it does take time to delete.
i just wanna know that sometime cascade delete does not work on the bulk data and records will remain orphan records in the system,Is it true?
if yes then i should go for the Web Application which is taking much time but feasible.or suggest the alternatives.
Like parent entity is "Account" and related Entities could be many.
So when i delete the Account "A" records (Parent Records), all the records related to "A" will be deleted from the all the related entities if any
What do you mean by "And these 50k records are from all the related entities."
Hi Shashikant,
The first option looks good - Cascade will trigger on bulk delete too!
Apart from it you can think of migration tools such as Scribe or SSIS to make this happen hassle free.
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6