Cascading delete from child to parent
I have an entity like this:
public class A{
public Guid Id;
public Guid Bid;
}
public class B{
public Guid Id;
}
How can I make so that B get deleted when A get deleted
5 Replies
Are you using EF Core, if so refer to: https://learn.microsoft.com/en-us/ef/core/saving/cascade-delete
Cascade Delete - EF Core
Configuring cascading behaviors triggered when an entity is deleted or severed from its principal/parent
Yes, but It doesn't seem to have anything about cascading delete in a one way relationship
Well why use a one-way relationship if you need cascading delete?
I was trying to find out a way to delete a utility class that can be used by other class but have no reference to the owner class
Mmm, have you tried using Fluent API to setup your relationship. I know it has a
.OnDelete
method maybe that could work?