I have a table of Transaction(Id, Comment, ClosingTransactionId). I would like the implement the "set null" functionality at deleting.
So if I have two rows:
(1, opening transaction, 2)
(2, closing transaction, null)
and I delete the second row, then the ClosingTransactionId of the first row should be set to null. I can add a foreign key constraint to ClosingTransactionId with "No action", but not with "set null" because SQL Server raises "cycles or multiple cascade paths".
Some page explain the problem, https://stackoverflow.com/a/12683993/5852947, some suggest to use triggers, https://stackoverflow.com/a/852047/5852947, other says anything is better than a trigger. Which way should I go? (Of course I could set ClosingTransactionId of the first row to null and then delete the second row, but I really would like the database would handle this.)
I use EF6 if it is any help.