title: Why does the action method get wrong parameter?
body: <p>I have the Action method and the View for editing properties of some items.</p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      [Authorize(Roles = "Admin")]
      public async Task&lt;ActionResult&gt; Edit(Item item)
      {
          if (ModelState.IsValid)
          {
              db.Entry(item).State = EntityState.Modified;
  
              await db.SaveChangesAsync();
              return RedirectToAction("Index");
          }
          ViewBag.CatagorieId = new SelectList(db.Catagories, "ID", "Name", item.CatagorieId);
          return View(item);
      }    
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@model OpenOrderFramework.Models.Item
  @using OpenOrderFramework.Extensions
  @{
      ViewBag.Title = "edit";
  }
  
  &lt;h2&gt;Editing&lt;/h2&gt;
  
  
  @using (Html.BeginForm())
  {
  
      &lt;div class="form-horizontal"&gt;
          &lt;h4&gt;The car&lt;/h4&gt;
          &lt;hr /&gt;
          @Html.ValidationSummary(true, "", new { @class = "text-danger" })
          @Html.HiddenFor(model =&gt; model.ID)
           &lt;-- etc --&gt;
  </code></pre>
  
  <p>But when I submit the form I get an error</p>
  
  <blockquote>
    <p>Store update, insert, or delete statement affected an unexpected number of rows (0).</p>
  </blockquote>
  
  <p>I figured out that in action method ID of the item that was posted is always 0 even if real ID of the item is different.
  <a href="https://i.stack.imgur.com/Y4XPZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y4XPZ.png" alt="enter image description here"></a>
  Why does it happen?</p>
  
  <p>GET Action method:</p>
  
  <pre><code>    // GET: Items/Edit/5
       [Authorize(Roles = "Admin")]
      public async Task&lt;ActionResult&gt; Edit(int? id)
      {
          if (id == null)
          {
              return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
          }
          Item item = await db.Items.FindAsync(id);
          if (item == null)
          {
              return HttpNotFound();
          }
          ViewBag.CatagorieId = new SelectList(db.Catagories, "ID", "Name", item.CatagorieId);
          return View(item);
      }
  </code></pre>