How to remove child one to many related records in EF code first database?

后端 未结 5 1972
逝去的感伤
逝去的感伤 2020-12-01 00:57

Well, I have one-to-many related model:

public class Parent
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<         


        
5条回答
  •  独厮守ぢ
    2020-12-01 01:11

    Try changing to

     public virtual ICollection Children { get; set; }
    

    because virtual is needed to get lazy loading. as explained here

    I think your parent.Children.clear isnt working because the Children have not been loaded

提交回复
热议问题