title: ASP.NET Core + Client Side Validation: No data-val-* attributes are generated if ViewBag and Model has same property name
body: <p>I realized in ASP.NET Core 2.2 that no data-val-* attributes are generated if ViewBag and Model has the same property name (in my case it is about the propery "Title"). Because of missing data-val-* attributes client side validation does not work.</p>
  
  <p>This is my Model:</p>
  
  <pre><code>public class ActivityModel
  {
      public int Id { get; set; }
  
      [Required]
      public string Title { get; set; }
  }
  </code></pre>
  
  <p>This is my View:</p>
  
  <pre><code>@model ActivityModel
  
  @{ ViewBag.Title = "This is my title"; }  
  
  @using (Html.BeginForm("Create", "Activities"))
  {
      @Html.EditorFor(model =&gt; model.Title)
  
      &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
  }
  
  @section Scripts {
      @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
  }
  </code></pre>
  
  <p>The ViewBag.Title property is used in _layout.cshtml to display the current title name.</p>
  
  <p>If I either change the ViewBag or Model property name to something else data-val-* attributes are generated and client side validation works. </p>
  
  <p>From the technical perspective what is causing this behaviour?</p>