title: DBContext, state and original values
body: <p>I'm working with ASP.NET MVC3 using EF and Code First.</p>
  
  <p>I'm writing a simple issue tracker for practice. In my Controller I have a fairly standard bit of code:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(Issue issue) {
      if (ModelState.IsValid) {
          dbContext.Entry(issue).State = EntityState.Modified
          .....
      }
  }
  </code></pre>
  
  <p>Question part 1
  I'm trying to get my head around how the dbcontext works -
  Before I've set the State on the dbContext.Entry(issue), I assume my issue object is detached. Once I set the state to be modified, the object is attached - but to what? the dbContext or the database? I'm kind of missing what this (attaching) actually means?</p>
  
  <p>Question part 2
  For argument's sake, let's say I decide to set the "Accepted" field on my issue. Accepted is a boolean. I start with it being false, I'm setting it to true in the form and submitting. At the point that my object is attached, what is the point of the OriginalValues collection? for example if I set a breakpoint just after setting EntityState.Modified but before I call SaveChanges()  I can query</p>
  
  <pre><code>db.Entry(issue).OriginalValues["Accepted"]
  </code></pre>
  
  <p>and this will give me the same value as simply querying the issue object that has been passed in to the Edit....i.e. it is giving the same result as</p>
  
  <pre><code>issue.Accepted
  </code></pre>
  
  <p>I'm clearly missing something because the documentation says
  "The original values are usually the entity's property values as they were when last queried from the database."
  But this is not the case because the database is still reporting Accepted as being false (yeah, I noted the word "usually" in the docs but my code is all pretty much standard generated by MS code so....).
  So, what am I missing? what is actually going on here?</p>