title: How to save an identity value of one table to foreign key of another table in entity framework?
body: <p>I have two tables: <code>user</code> and <code>userprofile</code></p>
  
  <p><code>User</code> has a column <code>id</code> which is an <code>identity</code> and is the primary key</p>
  
  <p><code>Userprofile</code> has the <code>userId</code> column which is a foreign key to <code>user.id</code>.</p>
  
  <pre><code>context.User.Add(userModel);
  context.UserProfile.Add(userprofileMode);
  context.SaveChanges();
  </code></pre>
  
  <p>But when I do <code>user.id = userprofile.Userid</code>, it doesn't save the value as it is identity column. How to save the value of id of user table to userid of userprofile table in Entity Framework?</p>