title: MVC 5 Create Validation error but valid ModelState
body: <p>I am trying to create within MVC 5 and am getting a validation error even though the ModelState is coming back valid.</p>
  
  <p><strong>Error message</strong></p>
  
  <blockquote>
    <p>Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.</p>
  </blockquote>
  
  <p>and when I look at the message, it shows....</p>
  
  <blockquote>
    <p>The name 'e' does not exist in the current context</p>
  </blockquote>
  
  <p>When I look at the POST data, the model that was created has all required fields filled in. I did notice that the model <code>ID</code> was assigned <code>0</code>. I'm not sure if that is the error or if it is supposed to pass a zero for the ID.</p>
  
  <p>What might the problem be?</p>
  
  <p>WosController.cs</p>
  
  <pre><code> [HttpPost]
   [ValidateAntiForgeryToken]
   public async Task&lt;ActionResult&gt; Create([Bind(Include = "id,woNumber,woDescription,dueDate,qty,item_id,releaseDate,parentWO_id,wip_id")] Wo wo)
      {
          if (ModelState.IsValid)
          {
              db.Wos.Add(wo);
              await db.SaveChangesAsync();
              return RedirectToAction("Index");
          }
  
          return View(wo);
      }
  </code></pre>
  
  <p>Wo.cs</p>
  
  <pre><code>public partial class Wo
  {
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
      public Wo()
      {
          this.WoParts = new HashSet&lt;WoPart&gt;();
          this.WoStatuses = new HashSet&lt;WoStatus&gt;();
      }
  
      public int id { get; set; }
      public string woNumber { get; set; }
      public string woDescription { get; set; }
      public Nullable&lt;System.DateTime&gt; dueDate { get; set; }
      public string qty { get; set; }
      public Nullable&lt;int&gt; item_id { get; set; }
      public Nullable&lt;System.DateTime&gt; releaseDate { get; set; }
      public string status { get; set; }
      public Nullable&lt;int&gt; parentWO_id { get; set; }
      public int wip_id { get; set; }
      public Nullable&lt;int&gt; part_id { get; set; }
  
      public virtual Item Item { get; set; }
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
      public virtual ICollection&lt;WoPart&gt; WoParts { get; set; }
      public virtual Wo woParentWO { get; set; }
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
      public virtual ICollection&lt;WoStatus&gt; WoStatuses { get; set; }
      public virtual Part Part { get; set; }
      public virtual Wip Wip { get; set; }
  }
  </code></pre>