There is similar code in the association classes already for generating conditions to delete dependent rows. Perhaps a way to get the association constraints for a given entity would be helpful.