title: Entity Framework Validation confusion - maximum string length of '128'
body: <p>I'm faced with a confusing problem where in my Edit or Create action result methods, EF4 will throw a DbEntityValidationException with the inner message stating:</p>
  
  <blockquote>
    <p>The field Body must be a string or
    array type with a maximum length of
    '128'.</p>
  </blockquote>
  
  <p>The model in question looks like this:</p>
  
  <pre><code>[Table("tblArticles")]
  public class Article
  {
      [Key]
      public int ID { get; set; }
      [Required(ErrorMessage="Title must be included")]
      public string Title { get; set; }
      [AllowHtml]
      public string Body { get; set; }
      [Required(ErrorMessage="Start Date must be specified")]
      [Display(Name="Start Date")]
      [DisplayFormat(DataFormatString="dd-mm-yyyy")]
      public DateTime? StartDate { get; set; }
      [Required(ErrorMessage = "End Date must be specified")]
      [Display(Name = "End Date")]
      public DateTime? EndDate { get; set; }
      public int Priority { get; set; }
      public bool Archived { get; set; }
  
      public virtual ICollection&lt;ArticleImage&gt; Images { get; set; }
  }
  </code></pre>
  
  <p>The "Body" field in the actual database is of type Text, so there's no obvious limit there.  The data that I'm trying to post is this:</p>
  
  <blockquote>
  <pre><code>&lt;p&gt;
  This is an example to confirm that new articles are looking right.&lt;/p&gt;
  &lt;p&gt;
  &lt;img alt="" src="http://www.google.co.nz/logos/2011/houdini11-sr.jpg"
  style="width: 160px; height: 56px; float: left;" /&gt;&lt;/p&gt;
  </code></pre>
  </blockquote>
  
  <p>An example of the Edit method looks like this:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Edit(Article article)
  {
      if (ModelState.IsValid)
      {
          try
          {
              articleRepository.Update(article);
          }
          catch (DbEntityValidationException dbevEx)
          {
              ErrorSignal.FromCurrentContext().Raise(dbevEx);
              ModelState.AddModelError("FORM", dbevEx);
              return View("Edit", article);
          }
          // Other exception handling happens...
      }
  
      return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>And finally, the method that actually does the grunt work is:</p>
  
  <pre><code>public void Update(T Entity)
  {
      dbset.Attach(Entity);
      db.Entry(Entity).State = System.Data.EntityState.Modified;
      db.Commit();
  }
  </code></pre>
  
  <p>I can't see anything in code or in the database that might be causing the problem, so where else should I look?</p>