Reputation: 796
We would like to change the deletebehavior from the nullable foreignkeys to cascade. So if we remove Item, we also would like to remove SubItemA and SubItemB if it is not null. We already tried several things with fluentapi, but we cannot seem to get to the correct solution. We really would like to keep the current models the way they are. Is there a possible solution? We are using EF core 3.1.
public class Item
{
public int Id { get; set; }
public int? SubItemAId { get; set; }
public SubItemA SubItemA { get; set; }
public int? SubItemBId { get; set; }
public SubItemB SubItemB { get; set; }
}
public class SubItemA
{
public int Id { get; set; }
public string Text { get; set; }
}
public class SubItemB
{
public int Id { get; set; }
public string Text { get; set; }
}
Upvotes: 5
Views: 563