title: ASP.Net MVC3 missing model properties
body: <p>I am new to MVC3 and am trying to write a blog application as a learning tool.</p>
  
  <p>I've created a database object for the blog post and generated a controller using the Controller with Read/Write actions and views using Entity Framework to control the entity.</p>
  
  <p>I'm having troubles with the edit commands. There are about 6 properties for a blog post but I only want to allow the edit to modify the title and content of the post. My code is as follows:</p>
  
  <pre><code>public ActionResult Edit(int id)
      {
          blog_Post blog_post = db.blog_Post.Find(id);
          return View(blog_post);
      }
  
      //
      // POST: /Post/Edit/5
  
      [HttpPost]
      public ActionResult Edit(blog_Post blog_post)
      {
          if (ModelState.IsValid)
          {
              db.Entry(blog_post).State = EntityState.Modified;
              db.SaveChanges();
              return RedirectToAction("Index");
          }
          return View(blog_post);
      }
  
  @model BlogVersion1._0.blog_Post
  
  @{
      ViewBag.Title = "Edit";
  }
  
  &lt;h2&gt;Edit&lt;/h2&gt;
  
  @using (Html.BeginForm()) {
  @Html.ValidationSummary(true)
  &lt;fieldset&gt;
      &lt;legend&gt;blog_Post&lt;/legend&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.Title)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.Title)
          @Html.ValidationMessageFor(model =&gt; model.Title)
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.PostContent)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.PostContent)
          @Html.ValidationMessageFor(model =&gt; model.PostContent)
      &lt;/div&gt;
  
      &lt;p&gt;
          &lt;input type="submit" value="Save" /&gt;
      &lt;/p&gt;
  &lt;/fieldset&gt;
  }
  
  &lt;div&gt;
  @Html.ActionLink("Back to List", "Index")
  &lt;/div&gt;
  </code></pre>
  
  <p>The problem that comes about is in the public ActionResult Edit(blog_Post blog_post) method. In the Edit(int id) method, I have put a breakpoint in and I can see that blog_post is being properly passed to the view (including all of its properties populated).</p>
  
  <p>But the blog_post being returned to the [HttpPost] method is missing properties for UserId, DateCreated, etc. An exception is obviously thrown on the db.SaveChanges call as required foreign keys are missing. </p>
  
  <p>How do I ensure that all properties are returned to the second edit method to properly make the update?</p>