Lazy Loading Items in Entity Framework

I have two objects that have a many to many relationship with each other.

I'm using Entity Framework in a Database First approach.

My Database Profiler is showing that everytime I fetch one set of objects A, it loads the other set of object B for each element in A. I assumed that with lazy loading, this wouldn't happen, or that B would be fetched when accessing via the navigation property.

The code to access the objects uses a generic approach, where entities is my DbContext

public virtual IQueryable<T> GetAll()
    IQueryable<T> query = entities.Set<T>();
    return query;

Both navigation properties are implemented as virtual ICollection<T> and I have Configuration.LazyLoadingEnabled = true explicitly set in my DbContext constructor.

Am I missing something, or approaching this the wrong way? Should I just remove the navigation properties and explicitly load what I need via other queries?


In the presence of the experts I am reluctant to ask this :) but would setting ProxyCreationEnabled=false on the DbContext not help in this case? Sorry if this is too "newbish" of a point

Need Your Help

Rails 3: MongoDB bug when querying sub documents with $in (working when querying root doc)

ruby-on-rails-3 mongodb mongoid

I have been trying this for a while now, and I came to the conclusion that it must be a bug in the mongo driver or something, but it makes no sense to me.

Circular buffer without modulo operation

c buffer code-review c99 circular-buffer

In Wikipedia it states that a modulo operation is required to check the available space in a circular buffer. However in my implementation I simply do:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.