title: update foreign key using entity framework
body: <p>i am trying to update foreign key in a table named(Friendship).The foreign key is of the table named(FriendshipStatus) the problem is that all the values are updated except the foreign key. I m using code first approach.</p>
  
  <p>Friendship Class</p>
  
  <pre><code>public class Friendship
  {
      public int Id { get; set; }
      public User UserOne { get; set; }
      public User UserTwo { get; set; }
      public FriendshipStatus Status { get; set; }
      public User ReqSB { get; set; }
      public RelationType RelationType { get; set; }
      public Relationship Relationship { get; set; }
      public DateTime FriendshipDate { get; set; }
  
  
  
  }
  </code></pre>
  
  <p>FriendshipStatus class</p>
  
  <pre><code>public class FriendshipStatus
  {
      public int Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>Here is the code for update</p>
  
  <pre><code> using (context)
          {
  
  
              Friendship f = getFrienshipRecord(u1, u2); // get single record from db which is to be updated
              if (f != null)
              {
                  Friendship ff = new Friendship();
                  ff.Status = new FriendshipStatus() { Id = 2}; //actually wants to update this this field
                  ff.Id = f.Id;
                  ff.FriendshipDate = DateTime.Now;
  
                  context.Entry(ff).State = EntityState.Modified;
                  context.SaveChanges();
  
  
              }
  
          }
  </code></pre>
  
  <p>The above code changes datetime but it does not change foreign key.</p>