title: How to use ValueGeneratedOnUpdate() correctly?
body: <p>I'm using <strong>EF Core 2.1.0-preview1-final CF approach</strong> with a <strong>MS SQL Server 2014</strong> and want to set on-update a time stamp in one column automatically. I already use <code>ValueGeneratedOnAdd</code> without any issues. When I insert a new record into my database the <code>InsertDateTimeUtc</code> column has the current UTC date and time value, the <code>UpdateDateTimeUtc</code> column has value <code>0001-01-01 00:00:00.0000000</code>, because it is a required column.</p>
  
  <p>Here is my test model (entity class).</p>
  
  <pre><code>public class Person
  {
      public string Name { get; set; }
  
      public DateTime InsertDateTimeUtc { get; set; }
  
      public DateTime UpdateDateTimeUtc { get; set; }
  
  
      public static void OnModelCreating(ModelBuilder modelBuilder)
      {
          var entity = modelBuilder.Entity&lt;Person&gt;();
  
          entity.Property(p =&gt; p.Name)
                .IsRequired();
  
          entity.Property(p =&gt; p.InsertDateTimeUtc)
                .HasDefaultValueSql("GETUTCDATE()")
                .ValueGeneratedOnAdd()
                .IsRequired();
  
          entity.Property(p =&gt; p.UpdateDateTimeUtc)
                .HasDefaultValueSql("GETUTCDATE()")
                .ValueGeneratedOnUpdate()
                .IsRequired();
      }
  }
  </code></pre>
  
  <p>As far as I tested <code>ValueGeneratedOnUpdate</code> does not work like I expected. If I update a record I would expect that the column <code>UpdateDateTimeUtc</code> will get the current UTC date and time value, but it does not change. The record (property <code>Name</code>) will be updated successfully - I set another value for property <code>Name</code> and could evaluate it.</p>
  
  <p>I could found <a href="https://stackoverflow.com/a/47581623/8330148">this SO answer</a> that contains following quote which seems to be from this <a href="https://docs.microsoft.com/en-us/ef/core/modeling/generated-properties" rel="noreferrer">MS doc article - Generated Values</a>.</p>
  
  <blockquote>
    <p>This just lets EF know that values are generated for added or updated entities, it does not guarantee that EF will setup the actual mechanism to generate values.</p>
  </blockquote>
  
  <p>But in mentioned MS doc article I could not find any information about the usage of <code>ValueGeneratedOnUpdate</code>. I already tried to use <code>ValueGeneratedOnAddOrUpdate</code> - too without success.</p>
  
  <p>Well, has somebody a hint how I could set a value for column <code>UpdateDateTimeUtc</code> in database automatically without any logic (like <code>person.UpdateDateTimeUtc = DateTime.UtcNow;</code>) in code please? Or could provide somebody a link where I could read further information?</p>