title: Update data using Entity Framework
body: <p>This is my view for editcar :</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;J2V.Models.vehicule&gt;" %&gt;
  //code
  &lt;% using (Html.BeginForm("editcar", "Agence", FormMethod.Post, new { @class = "search_form" })) { %&gt;
      &lt;%: Html.ValidationSummary(true) %&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;vehicule&lt;/legend&gt;
          // Those colonne will not be modified
          &lt;%: Html.HiddenFor(model =&gt; model.Matv) %&gt;
          &lt;%: Html.HiddenFor(model =&gt; model.Idag) %&gt;
          &lt;%: Html.HiddenFor(model =&gt; model.Idcat) %&gt;
          &lt;%: Html.HiddenFor(model =&gt; model.idmarque) %&gt;
          &lt;%: Html.HiddenFor(model =&gt; model.modele) %&gt;
  
          //Colonne to edit code
  
          &lt;p&gt;
              &lt;input type="submit" value="Save" /&gt;
          &lt;/p&gt;
      &lt;/fieldset&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>This is my controller action :</p>
  
  <pre><code>[HttpPost]
  public ActionResult editcar(Models.vehicule model)
  {
          if (ModelState.IsValid)
          {
              entity.vehicule.AddObject(model);
              entity.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified);
              entity.SaveChanges();
              return View("index", new { id = model.Idag });
          }
          else
              return View();
  }
  </code></pre>
  
  <p>When I click on the <code>Update</code> button I get this error :</p>
  
  <blockquote>
    <p>System.InvalidOperationException: The model item passed into the dictionary is of type '&lt;> f__AnonymousType2 <code>1 [System.String]' but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable</code> 1 [J2V.Models.vehicule] '.</p>
  </blockquote>