title: Getting DbEntityValidationException when I'm trying to update a row in a table using entity framework
body: <p>I'm trying to update a row in my table <code>bu.LastReviewCreationDate = LastReviewCreationDate;</code>, but this action generate a DbEntityValidationException. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>      public void UpdateLastReviewCreationDate(string idBusiness, DateTime LastReviewCreationDate,string urlSite) {
  
              DAL.Business bu;
              try {
                  using (DBContext tpContext = new DBContext())
                  {
                      bu = tpContext.business.Find(idBusiness, urlSite);
                      if (bu != null)
                      {
                          bu.LastReviewCreationDate = LastReviewCreationDate;
                          tpContext.SaveChanges();
                      }
                  }
              }
              catch (DbEntityValidationException e)
              {
                  foreach (var eve in e.EntityValidationErrors)
                  {
                      Console.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)
                      {
                          Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                              ve.PropertyName, ve.ErrorMessage);
                      }
                  }
                  throw;
              }
          }</code></pre>
  </div>
  </div>
  </p>
  
  <p>So This is what I got in the debugger: 
  <a href="https://i.stack.imgur.com/QGn2i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QGn2i.png" alt="enter image description here"></a></p>
  
  <p>That's means this table is Read-only and not allow editing. But I never set this table in Read-only, it's really strange. This is code of this table.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> public class Business
      {
          public Business()
          {
              LastReviewCreationDate = new DateTime();
          }
  
          [Key, Column(Order = 0)]
          public string Id { get; set; } 
  
          [Key, Column(Order = 1)]
          [ForeignKey("site")]
          public string SiteId { get; set; }
  
          public string UrlBusiness { get; set; }
          public DateTime LastReviewCreationDate { get; set; }
  
          [Required]
          public virtual Site site { get;set;}
          public virtual BusinessUser businessUser{get;set;}
  
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Maybe anyone has ideas? And is it possible that reset <code>IsReadOnly</code> parameter to <code>false</code>?</p>