title: Asp.Net MVC Reaching The Property Using Many To Many Relation
body: <p>In my model, a person(HrPerson) can have one more than titles(HrPersonTitle). So i have created below model to establish many to many relation between two models. </p>
  
  <p><strong>HrPerson Model :</strong></p>
  
  <pre><code>public class HrPerson
      {
          public int Id { get; set; }
          public string Name { get; set; }
          public virtual ICollection&lt;HrPersonTitle&gt; HrPersonTitle { get; set; }
      }
  </code></pre>
  
  <p><strong>HrPersonTitle Model :</strong></p>
  
  <pre><code>public class HrPersonTitle
      {
          public int Id { get; set; }
          public string Name { get; set; }
          public  ICollection &lt;HrPerson&gt; HrPerson { get; set; }
      }
  </code></pre>
  
  <p><strong>In my DbContext Class :</strong></p>
  
  <pre><code>    protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
  
          modelBuilder.Entity&lt;HrPerson&gt;()
              .HasMany(s =&gt; s.HrPersonTitle)
              .WithMany(c =&gt; c.HrPerson)
              .Map(t =&gt;
                   {
                       t.MapLeftKey("HrPersonId")
                       .MapRightKey("HrPersonTitleId")
                       .ToTable("HrMapPersonTitle");
                   });
      }
  </code></pre>
  
  <p>When i updated the DB, <strong>HrMapPersonTitle</strong> has been created. I think it is OK for many to many relation(?)</p>
  
  <p>My question is in controller action. My aim is to get all <em>title's name</em> which belongs to any person. I implemented the below code. </p>
  
  <p><strong>Controller :</strong></p>
  
  <pre><code>public PartialViewResult _ViewHrPersonTitle(int? personId)
  {
      var Titles = db.HrPersonTitle.Where(p =&gt; p.HrPerson.**(ID)???** = personId)
  
      return PartialView(Titles);
  }
  </code></pre>
  
  <p>It seems i could not reach the HrPerson-ID property from HrPersonTitle model. I think it is what it should be. 
  I wonder what is the best way to get the all Titles which belongs to a Person?</p>