title: Entity framework - use same entity twice in same object with one to many fluent api
body: <p>Sorry if the title is a bit unclear/ambiguous but I am unsure of how so get the following code bound via Fluent API (if it's even required)</p>
  
  <pre><code>public class ChatUser 
  {
      [Key]
      public int ChatUserId { get; set; }
      public string Name { get; set; }
  
      public bool IsOnline { get; set; }
      // other properties
  
      // navigation properties
      public ICollection&lt;ChatMessage&gt; Messages { get; set; }
  }
  
  public class ChatMessage
  {
      [Key]
      public int ChatMessageId { get; set; }
      public string Message { get; set; }
  
      public int UserFromId { get; set; }
      public int UserToId { get; set; }
  
      public DateTime DateSent { get; set; }
  
      // navigation properties
      public ChatUser UserFrom { get; set; }
      public ChatUser UserTo { get; set; }
  }
  </code></pre>
  
  <p>The problem I am having is to get the two <code>"ChatUser"</code> objects to be bound to the <code>UserFromId</code> and <code>UserToId</code> - they both come up as <code>null</code>.</p>
  
  <p>I need to be able to access a list of "Messages" from a user and when I've got a <code>Message</code> object, I need to be able to access both the <code>UserFrom</code> and <code>UserTo</code> so I can get the properties such as <code>Name</code>.</p>
  
  <p>If anyone could point me in the correct direction/any links that I can learn from that would be appreciated.</p>
  
  <p>PS if there is proper terminology for what I am trying to achieve could someone let me know - I was unsure of what to Google to solve my issue!</p>