title: Entity Framework Finding Entity via Foreign Keys
body: <p>I'm assuming this is bread &amp; butter for most..</p>
  
  <p>I have Roles, Permissions, and a RolePermissions entity to model many-to-many relationship.</p>
  
  <pre><code>public class RolePermission
  {
      [Key]
      public int ID { get; set; }
  
      //[Key, ForeignKey("Role"), Column(Order = 0)]
      public int RoleID { get; set; }
  
      //[Key, ForeignKey("Permission"), Column(Order = 1)]
      public int PermissionID { get; set; }
  
      //Navigational Properties
      public virtual Role role { get; set; }
      public virtual Permission permission { get; set; }
  }
  </code></pre>
  
  <p>I have an ActionResult to remove a given RolePermission, based on the RoleID and PermissionId that are passed in.</p>
  
  <pre><code>public ActionResult Remove(int Roleid, int Permissionid)
  {
    RolePermission rolepermission = db.RolePermissions
      .Include(p =&gt; p.PermissionID == Permissionid)
      .SingleOrDefault(p =&gt; p.RoleID == Roleid);
  
    db.RolePermissions.Remove(rolepermission);
    db.SaveChanges();
    return RedirectToAction("Index");  
  }
  </code></pre>
  
  <p>The above RolePermission rolepermission.. statement fails with </p>
  
  <pre><code>The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.
  Parameter name: path
  </code></pre>
  
  <p>.. which I'm not suprised, as it has one hell of a code smell to start with.</p>
  
  <p>What I'm after is the equivalent of</p>
  
  <pre><code>Delete from RolePermission
  Where RoleID = roleid
  AND PermissionID = permissionid
  </code></pre>
  
  <p>Any guidance?
  Many thanks</p>