Linq-to-entities – Include() method not loading

UPDATE: Actually I recently added another Tip that covers this, and provides an alternate probably better solution. The idea is to delay the use of Include() until the end of the query, see this for more information: Tip 22 – How to make include really include


There is known limitation in the Entity Framework when using Include().
Certain operations are just not supported with Include.

Looks like you may have run into one on those limitations, to work around this you should try something like this:

var results = 
   from e in dc.Entities //Notice no include
   join i in dc.Items on e.ID equals i.Member.ID
   where (i.Collection.ID == collectionID) 
   select new {Entity = e, Properties = e.Properties};

This will bring back the Properties, and if the relationship between entity and Properties is a one to many (but not a many to many) you will find that each resulting anonymous type has the same values in:

anonType.Entity.Properties
anonType.Properties

This is a side-effect of a feature in the Entity Framework called relationship fixup.

See this Tip 1 in my EF Tips series for more information.

Leave a Comment