1

I have an entity model:

class Test
{
    public virtual Address Address { get; set; }
}

class Address
{
    public virtual Town Town { get; set; }
}

Is there a way to eager load without using .Include.

The solution might look like this:

class Test
{
    [EagerLoad]
    public virtual Address Address { get; set; }
}

class Address
{    
    [EagerLoad]
    public virtual Town Town { get; set; }
}

This solves the problem of having to include Include on every method that retrieves a Test... It will always need its address included.

Jimmyt1988
  • 20,466
  • 41
  • 133
  • 233
  • I find that annoying as well. I've looked. Haven't found any other way myself. – Sam Axe Jul 01 '15 at 09:57
  • 2
    You can't, and you shouldn't want to. See http://stackoverflow.com/questions/18804850/entityframework-eager-load-all-navigation-properties, http://stackoverflow.com/questions/12064905/ef-code-first-forced-eager-loading, http://stackoverflow.com/questions/14512285/entity-framework-is-there-a-way-to-automatically-eager-load-child-entities-wit for some reading material. – CodeCaster Jul 01 '15 at 09:57

0 Answers0