title: EF Fluent API - retrieving related entities
body: <p>I have project class where each Project has its WorkOrders.
  Those are tables created in MySQL</p>
  
  <pre><code>CREATE TABLE `project` (
      `idProject` INT(11) NOT NULL AUTO_INCREMENT,
      `idCompany` INT(11) NOT NULL,
      `Title` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
      PRIMARY KEY (`idProject`, `idCompany`),
      INDEX `FK_project_company` (`idCompany`),
      CONSTRAINT `FK_project_company` FOREIGN KEY (`idCompany`) REFERENCES `company` (`idCompany`) ON UPDATE NO ACTION ON DELETE NO ACTION
  )
  ;
  
  CREATE TABLE `project_workorders` (
      `idProjectWO` INT(11) NOT NULL AUTO_INCREMENT,
      `idProject` INT(11) NOT NULL DEFAULT '0',
      `idWorkOrder` INT(11) NOT NULL DEFAULT '0',
      PRIMARY KEY (`idProjectWO`, `idProject`, `idWorkOrder`),
      INDEX `FK_project_workorders_project` (`idProject`),
      INDEX `FK_project_workorders_workorder` (`idWorkOrder`),
      CONSTRAINT `FK_project_workorders_project` FOREIGN KEY (`idProject`) REFERENCES `project` (`idProject`) ON UPDATE NO ACTION ON DELETE NO ACTION,
      CONSTRAINT `FK_project_workorders_workorder` FOREIGN KEY (`idWorkOrder`) REFERENCES `workorder` (`idWorkOrder`) ON UPDATE NO ACTION ON DELETE NO ACTION
  );
  </code></pre>
  
  <p>And then there are FluentAPI configuration files</p>
  
  <pre><code>class ProjectConfiguration : EntityTypeConfiguration&lt;Project&gt;
      {
          internal ProjectConfiguration()
          {
              this.HasKey(p =&gt; new { p.idProject , p.idCompany});
              this.Property(p =&gt; p.idProject)
                  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
              this.HasRequired&lt;MaxUser&gt;(p =&gt; p.CreatedByUser)
                  .WithMany()
                  .HasForeignKey(p =&gt; p.CreatedByID);
              this.HasMany(s =&gt; s.ProjectWO)
                  .WithRequired(w=&gt;w.Project)
                  .HasForeignKey(k=&gt;new { k.idProject,k.idProjectWO});
              this.Map(m =&gt;
              {
                  m.MapInheritedProperties();
              });
          }
      }
  
      class ProjectWOConfiguration : EntityTypeConfiguration&lt;ProjectWO&gt;
      {
          internal ProjectWOConfiguration()
          {
              this.HasKey(p=&gt; new { p.idProjectWO , p.idProject, p.idWorkOrder });
              this.Property(p =&gt; p.idProjectWO)
                  .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
              this.HasRequired&lt;MaxUser&gt;(p =&gt; p.CreatedByUser)
                  .WithMany()
                  .HasForeignKey(p =&gt; p.CreatedByID);
              this.Map(m =&gt;
              {
                  m.MapInheritedProperties();
              });
          }
      }
  </code></pre>
  
  <p>The problem is I can not get related entities to appear in Project object.
  No matter what I try , the ProjectWO sub-object is always empty.</p>
  
  <p><a href="https://i.stack.imgur.com/XmhB1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XmhB1.png" alt="enter image description here"></a></p>
  
  <p>Any help is appreciated.</p>