c# – Garbage collection in the database

Question:

Two models are connected in a one-to-many relationship, if you delete this very one – it is clear that all many will be deleted if you do not specify WillCascadeOnDelete(false) . But I need an inverse problem to automatically delete one when all many dependent on it are deleted.

Answer:

It comes to mind to hang up some kind of trigger on the database, which will check when many are deleted, nothing refers to a single element => crashes next.

You can make a JOB that will check items from time to time and remove " garbage ".

Scroll to Top
AllEscort