title: Update User Foreign Key MVC 5
body: <p>Currently, I have a custom user.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ApplicationUser : IdentityUser&lt;int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim&gt;
  {
      public ApplicationUser()
  {
  this.Applicants = new List&lt;Applicant&gt;();
  }
  
  public Nullable&lt;DateTime&gt; Expiration { get; set; }
  public int Active { get; set; }
  
          public Company Company { get; set; }
          public Department Department { get; set; }
  
          public ICollection&lt;Applicant&gt; Applicants { get; set; }
  
          public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(ApplicationUserManager manager)
          {
              var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
  
              // Add custom user claims here
              return userIdentity;
          }
      }
  </code></pre>
  
  <p>The Company Class</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Company
  {
      public int Id { get; set; }
      public string Name { get; set; }
  
      public ICollection&lt;Department&gt; Departments { get; set; }
      public ICollection&lt;ApplicationUser&gt; Users { get; set; }
  }
  </code></pre>
  
  <p>I want to update the User class so that it points to the company when the company is created; however, the update does not save. Here is the section of my controller where I am attempting to save the reference in the database. ApplicationUser should point to the ID of Company in the database.</p>
  
  <pre class="lang-cs prettyprint-override"><code>// _db is for my Identity context
  int id = Convert.ToInt32(User.Identity.GetUserId());
  ApplicationUser user = UserManager.FindById(id);
  Company company = new Company
  {
      Name = model.Name
  };
  _db.Companies.Add(company);
  _db.SaveChanges();
  user.Company = company;
  UserManager.Update(user);
  </code></pre>
  
  <p>So what am I doing wrong or misunderstanding about the relationship between a user and it's relationships with objects rather than regular datatypes like string or int?</p>