title: Optimistic concurrency: IsConcurrencyToken and RowVersion
body: <p>I'm creating the default concurrency strategy that I will use in my application.</p>
  
  <p>I decided for an optimistic strategy.</p>
  
  <p>All of my entities are mapped as <code>Table per Type (TPT)</code> (using inheritance). I soon learned that there is a problem when using columns of type RowVersion with inheritance on Entity Framework:</p>
  
  <pre><code>Product
  
  Id INT IDENTITY PRIMARY KEY
  RowVersion ROWVERSION
  
  Car (inherits Product records)
  
  Color TYNIINT NOT NULL,
  AnotherProperty....   
  </code></pre>
  
  <p>If I update a record of the <code>Car</code> table the RowVersion column from <code>Product</code> table will not be updated.</p>
  
  <p>I plan to use a column of type <code>datetime2 (7)</code> in <code>Product</code> and update it manually if any records of the tables that inherit this table are modified.</p>
  
  <p>I think I'm reinventing the wheel.</p>
  
  <p>Is there another way to use the optimistic concurrency strategy with <code>ROWVERSION</code> when using <code>Table per Type (TPT)</code> in Entity Framework?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>My mapping:</p>
  
  <pre><code>class Product
  {
      int Id { get; set; }
      string Name { get; set; }
      byte[] RowVersion { get; set; }
  }
  
  class Car : Product
  {
      int Color { get; set; }
  }
  </code></pre>
  
  <p><strong>CodeFirst</strong> conventions.</p>
  
  <p>Only the RowVersion property on <code>Product</code> entity has custom definitions:</p>
  
  <pre><code>modelBuilder.Entity&lt;Product&gt;() 
      .Property(t =&gt; t.RowVersion) 
      .IsConcurrencyToken();
  </code></pre>