I've been searching a bit on this but thus far haven't been able to find a decent solution. I'm trying to get an entity from my database without the related entities attached to it.
The function goes as following return context.Entity.SingleOrDefault(n => n.Name == name)
where context is a DbContext
.
As of now the reply contains only one Entity but with an added 50 "child" entities which I do not need.
What would be the best way to go about getting a single entity from the db?
Using EFC2.1 pre release build
Also found that if you use DbContext.Entity.AsNoTracking
you can get the entity without the child collections.
Not sure if the full entity will be saved after making changes and calling DbContext.saveChanges()
You have to enable Lazy Loading, simply add a property to your class like this.
public virtual ICollection<ChildType> NavigationProperty;
Here is a very useful document for Loading Related Data.