Scenario:
public class A{
public B InstanceOfB { get; set; }
}
public class B{
public string Name { get; set; }
public virtual ICollection<A> ListOfA { get; set; }
}
public void Boo(){
using (var db = new myContext()){
var instanceOfA = db.A.Find(1);
db.Entry(instanceOfA).Reference(a => a.InstanceOfB).Load();
}
}
In my dbcontext I turned off ProxyCreationEnabled and turned on LazyLoadingEnabled.
When I use Load
the reference of property ListOfA
is loaded too and it's recursive.
How can I prevent this behavior ?