title: Validation failed for one or more entities. See 'EntityValidationErrors' property
body: <p>I am new in ASP.NET and I am trying to decorate an action method to allow an administrator to create new user by inserting the first, last names and the balance. The action method should generates Id, account number and AppUserId in the checkingaccount table. However, the post Create action throws the following exception because I am not passing AppUserId </p>
  
  <blockquote>
    <p>Validation failed for one or more entities. See
    'EntityValidationErrors' property for more details.</p>
  </blockquote>
  
  <p>Is there away I can make the AppuserId added on the table?</p>
  
  <p>Create Action Method</p>
  
  <pre><code> [HttpPost]
          public ActionResult Create(string FName, string LName, string UserId, decimal balance)
          {
  
                  var accountNumber = (12 + db.checkAccounts.Count()).ToString().PadLeft(10, '0');
                  var checking = new CheckingAccount
                  {
                      FirstName = FName,
                      LastName = LName,
                      AccountNumber = accountNumber,
                      Balance = balance,
                      AppUserId = UserId
                  };
                  db.checkAccounts.Add(checking);
                  db.SaveChanges();
  
                  return RedirectToAction("ViewAccounts");
  
          }
  </code></pre>
  
  <p>CheckingAccount Model</p>
  
  <pre><code>public class CheckingAccount
      {
          public int Id { get; set; }
  
          public string AccountNumber { get; set; }
  
          public string FirstName { get; set; }
  
          public string LastName { get; set; }
  
          public string Telephone { get; set; }
  
  
          public decimal Balance { get; set; }
  
          public virtual ApplicationUser User { get; set; }
          [Display(Name = "User ID: ")]
          [Required]
          public string AppUserId { get; set; }
  
      }
  </code></pre>
  
  <p>CheckingAccount Model</p>
  
  <pre><code>@model Project.Models.CheckingAccount
  
  @{
      ViewBag.Title = "Create";
  }
  
  @using (Html.BeginForm()) 
  {
      @Html.AntiForgeryToken()
  
      &lt;div class="form-horizontal"&gt;
          &lt;h4&gt;Checking Account&lt;/h4&gt;
          &lt;hr /&gt;
          @Html.ValidationSummary(true, "", new { @class = "text-danger" })
  
          @Html.ValidationSummary(true, "", new { @class = "text-danger" })
          @Html.HiddenFor(model =&gt; model.AccountNumber)
   &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.FirstName, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.LastName, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.LastName, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;div class="form-group"&gt;
              @Html.LabelFor(model =&gt; model.Balance, htmlAttributes: new { @class = "control-label col-md-2" })
              &lt;div class="col-md-10"&gt;
                  @Html.EditorFor(model =&gt; model.Balance, new { htmlAttributes = new { @class = "form-control" } })
                  @Html.ValidationMessageFor(model =&gt; model.Balance, "", new { @class = "text-danger" })
              &lt;/div&gt;
          &lt;/div&gt;
  
           @Html.ValidationSummary(true, "", new { @class = "text-danger" })
           @Html.HiddenFor(model =&gt; model.AppUserId)
  
  
          &lt;div class="form-group"&gt;
              &lt;div class="col-md-offset-2 col-md-10"&gt;
                  &lt;input type="submit" value="Create" class="btn btn-default" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  }
  
  &lt;div&gt;
       @Html.ActionLink("Back", "ViewAccounts", null, new { @class = "btn btn-info" })
  &lt;/div&gt;
  
  @section Scripts {
      @Scripts.Render("~/bundles/jqueryval")
  }
  </code></pre>