title: What's the simplest approach to friends list in EF?
body: <p>I would like to create a simple friend list, with each row having two id's (user id and friend id), both referencing "id" field in respective user's profile</p>
  
  <p>|relationId|userId|friendId|</p>
  
  <p>So that users become friends if both sides send a friendship request to eachother. For example:<br>
  |1|2|4|<br>
  |1|4|2|   //users with id 2 and 4 are friends</p>
  
  <p>Setting up a foreign key has been easy for me so far. Things get harder when I have to set up two foreign keys to the same table. I am getting different errors which I look to fix and then re-adjust my code and in the end I feel like I am overcomplicating this.</p>
  
  <p>UserProfile model: </p>
  
  <pre><code>[Table("UserProfile")]
  public class UserProfile
  {
      [Key]
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public int UserId { get; set; }
      public string UserName { get; set; }
      public string Email { get; set; }
  }
  </code></pre>
  
  <p>Friends model:</p>
  
  <pre><code>[Table("Friends")]
  public class Friends
  {
      [Key]
      [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
      public int RelationId { get; set; }
  
      public int UserId { get; set; }
  
      [ForeignKey("UserId")]
      public UserProfile User { get; set; } // works with one foreign key
  
      public int FriendId { get; set; }
  
      [ForeignKey("FriendId")]
      public UserProfile Friend { get; set; } // doesn't work when I add this one
  }
  </code></pre>
  
  <p>This gives me the following exception:   </p>
  
  <blockquote>
    <p>Introducing FOREIGN KEY constraint 'Friends_User' on table 'Friends' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.</p>
  </blockquote>
  
  <p>I have searched for similar problems, I have seen examples with many foreign keys, however, I wasn't able to find any example with two fields linked to the same table. </p>