title: .NET Core submit passes all the data to the controller except for the id
body: <p>.NET Core 3.1 with EF Core, trying to update data loaded into a form, but for some reason it sets the Id = 0 on submit, and I have no idea why. Or, if I explicitly set the id value, the controller gets a null value for all the records. Importantly, it's a list of entities that I'm sending down to the db.</p>
  <p>I can create multiple records just fine using the same form. But if I load the form with existing records, and want to make changes, I can't. The Id of each record gets set to zero, if I don't put the Id in for each record. If I do put the Id of each record, the form seems to submit correctly, as I'm looking at Chrome DevTools and see that the values are there, including the Id, but then the controller gets that data, and it's null...</p>
  <p><strong>ETA</strong> It looks like the 41st row is causing the issue when I do submit the form with the Id included for each row. What I don't know is if that means 41 rows is too many, or there is some issue with the data itself, which means the controller won't pick up any of it...but neither of these make sense, since the form loads the 62 rows just fine.</p>
  <p>Here's a simplified version of it, with key pieces included so it makes sense.</p>
  <p>My model:</p>
  <pre><code>@model List&lt;EvaluationsModel&gt;
  </code></pre>
  <p>My form:</p>
  <pre><code>@{
      var createOrUpdate = &quot;Update&quot;;
      if (Model[0].IsCreate)
      {
         createOrUpdate = &quot;Create&quot;;
      }
  }       
  
  &lt;form id=&quot;evalForm&quot; asp-action=&quot;@createOrUpdate&quot;&gt;
  
  @for (var i = 0; i &lt; Model.Count; i++)
  {
      &lt;textarea asp-for=&quot;@Model[i].Comments&quot; rows=&quot;5&quot; cols=&quot;75&quot;&gt;&lt;/textarea&gt;
      &lt;input asp-for=&quot;@Model[i].Id&quot; type=&quot;hidden&quot; /&gt;
  }
  
  &lt;input type=&quot;submit&quot; id=&quot;submitButton&quot; value=&quot;@createOrUpdate&quot; class=&quot;btn btn-primary&quot; /&gt;
  </code></pre>
  <p>My controller method:</p>
  <pre><code>public IActionResult Update(List&lt;EvaluationsModel&gt; evalRows)
  {
     _dostuffWith(evalRows);
     return Redirect(toGet);
  }
  </code></pre>