try the following:
Company company = context.Companies.Include("Address").Find(id);
or with the new typed syntax:
Company company = context.Companies.Include(c => c.Address).Find(id);
This tells EF to eagerly load the Address object as part of your Company object.
It also seems that you have a repository layer on top of EF - make sure your repository implementation supports Include() , if this is the case.
For starters only, this is the Include() implementation that Julia Lerman provides in the Entity Framework Program to support the tested repository pattern with POCOS (this version only works with the first syntax):
public static IQueryable<TSource> Include<TSource>(this IQueryable<TSource> source, string path) { var objectQuery = source as ObjectQuery<TSource>; if (objectQuery != null) { return objectQuery.Include(path); } return source; }
Brokenglass
source share