title: Entity framework Eager and Lazy load
body: <p>Trying to figure out the difference between Lazy and Eager loading in entity frameowrk. Say I have the following models:</p>
  
  <pre><code>public interface IBaseEntityObject 
  {
      public int Id {get; set;}
  }
  
  
  public abstract class BaseEntityObject : IBaseEntityObject
  {
      [Key]
      [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
      public int Id {get; set;}
  }
  
  
  public class Folder : BaseEntityObject
  {   
      [DataMember]
      public string Name {get; set;}
  
      [DataMember]
      public virtual List&lt;Letter&gt; Letters {get; set;} 
  }
  
  
  public abstract class Letter : BaseEntityObject
  {   
      [DataMember]
      public string Title {get; set;}
  
      [DataMember]
      public string Content {get; set;}
  
      public virtual Folder Folder {get; set;}
  
      [DataMember]
      public int FolderId {get; set;}
  
      [DataMember]
      public DateTime CreationDate {get; set;}
  }
  
  public class OutgoingLetter : Letter
  {
      // .. OutgoingLetter properties
  }
  
  public class ReceviedLetter : Letter
  {
      // .. ReceviedLetter properties
  }
  
  
  public class MyDbContext : DbContext
  {
      public DbSet&lt;Folder&gt; Folders {get; set;}
  
      public DbSet&lt;Letter&gt; Letters {get; set;}
  
  
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
  
          // Folder &lt;-&gt; Letters       
          modelBuilder.Entity&lt;Letter&gt;()
          .HasRequired(t =&gt; t.Folder)
          .WithMany(f =&gt; f.Letters)
          .HasForeignKey(t =&gt; t.FolderId)
          .WillCascadeOnDelete(true);
      }
  }
  </code></pre>
  
  <p>Whenever I ask a folder from the data base, it's main purpose is for accessing the Letters in it.. Therefore, will it be best if I already load it from the beginning instead of making another database call when accessing the Letters property am I correct?</p>
  
  <p>I've read that disabling the Lazy load is done by configuring it in the ctor with by setting the EnableLazyLoading property to false and removing virtual key word from the letters list. </p>
  
  <p>What would be the difference if I just use Include(x => x.Lettters) whenever I ask for a folder and keep the Lazy loading enabled? Include can not be used when Lazy loading is enabled? </p>
  
  <p>Moreover is there any relation between the Folder property that is held in Letter model to the lazy loading? I don't use the Folder when asking for a letter, yet most models around I've seen contain the Father property in one to many relationship and I don't really understand why. </p>
  
  <p>Thanks!</p>