title: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. Code First
body: <p>I get this error:</p>
  
  <pre><code>Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
  </code></pre>
  
  <p>when i try to update the database with the <code>Update-Database</code> command in the Package Manager Console.</p>
  
  <p>How can I write the lines to the output window in visual studio?</p>
  
  <p>I tried:</p>
  
  <pre><code>try
  {
      context.SaveChanges();
  }
  catch (System.Data.Entity.Validation.DbEntityValidationException e)
  {
      foreach (var eve in e.EntityValidationErrors)
      {
          System.Diagnostics.Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
              eve.Entry.Entity.GetType().Name, eve.Entry.State);
          foreach (var ve in eve.ValidationErrors)
          {
              System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                  ve.PropertyName, ve.ErrorMessage);
          }
      }
      throw;
  }
  </code></pre>
  
  <p>But that didn't work. Any other suggestions on how to debug this?</p>