Is there any way in Linq to check to see if a record of a parent exists in its children?
I have a table that has a foreign key relationship with 12 other tables. All I want to do is see if any records in those child tables depend on the parent, so I can delete it without causing errors with FK constraints.
Thanks guys.
I ended up just making an extension class that checked each one… Time consuming but got the job done… I would still like opinions if possible
You could brute-force it and wrap the delete in a try-catch. As long as all the deletes are part of the same context, if one child can’t be deleted due to a FK relationship, it will roll back all the deletes in that block.