title: Best way to override SaveChanges()
body: <p>We have worked on a project for 1 month and there are 6 entities without any relationship with other entities. They are all simple entities. </p>
  
  <p>We have created 6 different classes for operations on each entity. <code>SaveOrUpdateEntity()</code> methods of classes are almost same as you think. It is something like that:</p>
  
  <pre><code>public static ErrorType SaveOrUpdateEntity(Entity entity, int userID)
  {
      try
      {
          using (DataEntities ctx = new DataEntities())
          {
              if (entity != null)
              {
                  if (entity.entityID == 0)
                  {
                      entity.CreateDate = DateTime.Now;
                      entity.CreatedBy = userID;
  
                      ctx.Entry(entity).State = EntityState.Added;
                  }
                  else
                  {
                      entity.ModifyDate = DateTime.Now;
                      entity.ModifiedBy = userID;
  
                      ctx.Entry(entity).State = EntityState.Modified;
                  }
              }
  
              ctx.SaveChanges();
          }
  
          return ErrorType.NoError;
      }
      catch (Exception ex)
      {
          return ErrorType.SaveError;
      }
  }
  </code></pre>
  
  <p>It would be very helpful, if <code>SaveOrUpdateEntity()</code> method is shorter and more generic by overriding <code>SaveChanges()</code> method. According to other questions, articles, and posts about overriding <code>SaveChanges()</code> method, implementing interface that stores state of entities is a good solution but I am also wondering other solutions.</p>
  
  <p>Because I am newbie, all answers would be very appreciated.</p>
  
  <p>Thank you.</p>