是否可以在不加载 EF6 的情况下修改实体上的导航集合?

时间:2021-06-10 13:13:00

标签: c# .net entity-framework-6

public class Parent
{
    public virtual Guid Id {get; set;}

    public virtual ICollection<Child> Children {get; set;}
}

public class Child
{
    public virtual Guid Id {get; set;}

    //More properties...
}

鉴于上述对象,我知道我可以从上下文中获取父实体,并通过实例化子对象、设置主键、调用 Attach 方法,然后在上的 Add 方法将关系添加到现有的 Child 实体Children 集合,即无需加载整个 Child 实体。

我的理解是,无论“Children”是否延迟加载,我们都必须加载这些实体才能从集合中添加或删除。

有没有办法在不加载任何涉及的实体的情况下修改这些关系? (SQL 除外)

0 个答案:

没有答案