title: .net core 2.1 validation state: invalid
body: <p>The following simple .NET Core 2.1 MVC code reports "Validation State: Invalid" when I submit to create. Everything works fine without the Owner property; and it works if Owner property is not required.</p>
  
  <p>The Owner is the current user which is in the context of the server side, and it shouldn't be submitted from a client side, so the Create.cshtml doesn't have a Owner input in the form.</p>
  
  <p>The error:</p>
  
  <pre><code>info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
        Executing action method AnnouncementApp.Controllers.AnnouncementsController.Create (AnnouncementApp) with arguments (AnnouncementApp.Models.Announcement) - Validation state: Invalid
  </code></pre>
  
  <p>The model:</p>
  
  <pre><code>using System;
  using Microsoft.AspNetCore.Mvc;
  using System.ComponentModel.DataAnnotations;
  using Microsoft.AspNetCore.Mvc.ModelBinding;
  using AnnouncementApp.Models.Attributes;
  using Microsoft.AspNetCore.Identity;
  //using System.Security.Claims;
  
  namespace AnnouncementApp.Models
  {
      public class Announcement
      {   
          public int ID { get; set; }
          [Required]
          public string Content { get; set; }
          [Display(Name = "Start Date and Time")]
          public DateTime StartDate { get; set; }
  
          [StartEndDate("End Date and Time must be after Start Date and Time")]
          [Display(Name = "End Date and Time")]
          public DateTime EndDate { get; set; }
  
          [Required]
          [BindNever]
          public IdentityUser Owner { get; set; }
      }   
  }
  </code></pre>
  
  <p>The controller method:</p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      public async Task&lt;IActionResult&gt; Create([Bind("ID,Content,StartDate,EndDate")] Announcement announcement)
      {
          if (ModelState.IsValid)
          {
              var user = await _userManager.GetUserAsync(this.User);
              announcement.Owner = user;
              _context.Add(announcement);
              await _context.SaveChangesAsync();
              return RedirectToAction(nameof(Index));
          }
          return View(announcement);
      }
  </code></pre>
  
  <p>The Create.cshtml</p>
  
  <pre><code>@model AnnouncementApp.Models.Announcement
  
  @{
      ViewData["Title"] = "Create";
  }
  
  &lt;h2&gt;Create&lt;/h2&gt;
  
  &lt;h4&gt;Announcement&lt;/h4&gt;
  &lt;hr /&gt;
  &lt;div class="row"&gt;
      &lt;div class="col-md-4"&gt;
          &lt;form asp-action="Create"&gt;
              &lt;div asp-validation-summary="ModelOnly" class="text-danger"&gt;&lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label asp-for="Content" class="control-label"&gt;&lt;/label&gt;
                  &lt;textarea asp-for="Content" class="form-control"&gt;&lt;/textarea&gt;
                  &lt;span asp-validation-for="Content" class="text-danger"&gt;&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label asp-for="StartDate" class="control-label"&gt;&lt;/label&gt;
                  &lt;input asp-for="StartDate" class="form-control" /&gt;
                  &lt;span asp-validation-for="StartDate" class="text-danger"&gt;&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;label asp-for="EndDate" class="control-label"&gt;&lt;/label&gt;
                  &lt;input asp-for="EndDate" class="form-control" /&gt;
                  &lt;span asp-validation-for="EndDate" class="text-danger"&gt;&lt;/span&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div&gt;
      &lt;a asp-action="Index"&gt;Back to List&lt;/a&gt;
  &lt;/div&gt;
  
  @section Scripts {
      @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
  }
  </code></pre>