Hi,
do you have a standard solution for the removal of referenced key? An example:
public class UM : FullAuditedEntity, IMustHaveTenant { ... } public class Article : FullAuditedEntity, IMustHaveTenant { ... [Required] [ForeignKey("UM_Stock_Id")] public virtual UM UM_Stock { get; set; } public virtual int? UM_Stock_Id { get; set; } ... }
Now:
- I add UM #1
- I add Article X adding a reference to UM #1
- If I try to remove UM #1 I need to raise an error, actually UM #1 is marked as deleted and the Article X contains the reference to the deleted record on UM.
Thank you
1 Answer(s)
-
0
Are you trying to ask "How to throw an exception for
DeleteBehavior.Restrict
(Cascade Delete) on soft delete"?There is no standard solution. If you want to implement a general solution, you can look at an attempt at
DeleteBehavior.Cascade
on soft delete (aspnetboilerplate/aspnetboilerplate#3559) for inspiration. I thinkRestrict
does not have the same blocking issues, since you only need to visit one level unlike cascade delete, but it may still be non-trivial.