title: How to include related table in LINQ query?
body: <p>I have two classes, <strong>Company</strong> and <strong>CompanyAddress</strong>.</p>
  
  <p>For every <strong>Company</strong> there can be multiple <strong>CompanyAddresses</strong>, such as Invoice address and correspondence address.</p>
  
  <p>Via entity framework, I'm trying to include all <strong>CompanyAddresses</strong> that belong the <strong>Company</strong>. However, I keep getting the following debug error:</p>
  
  <p><em>An exception of type 'System.InvalidOperationException' occurred in System.Data.Entity.dll but was not handled in user code
  Additional information: A specified Include path is not valid. The EntityType 'StatelyTechAdmin.Models.Company' does not declare a navigation property with the name 'CompanyAddresses'.</em></p>
  
  <p>Can anyone advise me on why I cannot include all addresses in my LINQ query? Please note I am very new to Entity Framework.</p>
  
  <p><strong>Company Class</strong></p>
  
  <pre><code>public class Company
  {
      [Key]
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public virtual long CompanyId { get; set; }
  
      [Required]
      [Display(Name = "Company Name")]
      public virtual string Name { get; set; }
  
      public virtual DateTime CreatedDate { get; set; }
  
      public virtual IEnumerable&lt;CompanyAddress&gt; CompanyAddresses { get; set; }
  }
  </code></pre>
  
  <p><strong>CompanyAddress Class</strong></p>
  
  <pre><code>public class CompanyAddress
  {
      [Key]
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public virtual long CompanyAddressId { get; set; }
  
      [Required]
      public virtual long CompanyId { get; set; }
  
      [ForeignKey("CompanyId")]
      public virtual Company Company { get; set; }
  
      [Required]
      public virtual int CompanyAddressTypeId { get; set; }
  
      [ForeignKey("CompanyAddressTypeId")]
      public virtual CompanyAddressType CompanyAddressType { get; set; }
  
      [Display(Name = "Address 1")]
      public virtual string Address1 { get; set; }
  
      [Display(Name = "Address 2")]
      public virtual string Address2 {get; set; }
  
      [Display(Name = "Town")]
      public virtual string Town { get; set; }
  
      [Display(Name = "City")]
      public virtual string City { get; set; }
  
      [Required]
      public virtual long CountyId { get; set; }
  
      [ForeignKey("CountyId")]
      [Display(Name = "County")]
      public virtual County County { get; set; }
  
      [Required]
      [Display(Name = "Postal Code")]
      public virtual string PostalCode { get; set; }
  
      public virtual DateTime CreatedDate { get; set; }
  }
  </code></pre>
  
  <p><strong>Calling Method from MVC Action</strong></p>
  
  <pre><code>public ActionResult Index()
      {
          var comp = db.Companies.Include(a =&gt; a.CompanyAddresses).ToList();
  
          return View(comp);
      }
  </code></pre>
  
  <p>All advice welcome! Thank you for your time.</p>