This issue can be resolved in a simpler way.
Actually, the reason for this is your one-to-many relationship. There are two options available when you want to delete One Side: cascade delete or none.
When you choose the first option, all the numerous side entities will be deleted together with the one side. This setting is available in the entity diagram. Only the relationship must be chosen, and the "End1 OnDelete" attribute must be set to Cascade.