title: Add object to context and get properties from the relationship
body: <p>I made a while ago some code that adds an object to my table with entity framework code first.</p>
  
  <pre><code>Context.Reactions.Attach(reaction);
  Context.SaveChanges();
  </code></pre>
  
  <p>After that I used a relationship called Profile to get the name of the user that posted the reaction.</p>
  
  <pre><code>reaction.Profile.FirstName + " " + reaction.Profile.LastName
  </code></pre>
  
  <p>Now after a while, I get a nullreference on Profile when I try to get the name of the person. </p>
  
  <p>So why can't I add an object and after that use the Profile relationship?</p>
  
  <p>Edit:
  I'm getting the nullreference on the Profile relation property. So reaction.Profile says that is null. It is the same instance. Entity Framework has given me an id for the reaction so the savechanges() works.
  The line for getting the FirstName is the line directly after the SaveChanges so the context couldn't be disposed right?</p>
  
  <p>Complete code:</p>
  
  <pre><code>var reaction = new Reaction()
                                  {
                                      Text = reactionText,
                                      ProfileId = CurrentProfileId,
                                      PostedOn = DateTime.Now
                                  };
  
                      //Save changes to the backend
                      context.Reactions.Add(reaction);
                      context.SaveChanges();
  
                      return Json(new
                      {
                          Id = reaction.Id,
                          ReactionType = reactionType,
                          ReactionTypeId = reactionTypeId,
                          ReactionText = reaction.Text,
                          PostedOn = reaction.PostedOn.ToString("G"),
                          ProfileName = string.Format("{0} {1}", reaction.Profile.FirstName, reaction.Profile.LastName)
                      });
  </code></pre>
  
  <p>I even tryed with this code around it.</p>
  
  <pre><code>using (var context = new SeeTingsContext())
                  {
                      context.Configuration.LazyLoadingEnabled = true;
  
  
                  }
  </code></pre>