See also: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations
21 lines
675 B
C#
21 lines
675 B
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace EntityFrameworkCore.Domain;
|
|
// Since C#11, you do not need to wrap in accolades anymore.
|
|
public abstract class BaseDomainModel
|
|
{
|
|
public int Id { get; set; } // Anything called "Id" is automatically a Primary Key.
|
|
public DateTime CreatedDate { get; set;}
|
|
public DateTime ModifiedDate { get; set;}
|
|
public string? CreatedBy { get; set; }
|
|
public string? ModifiedBy { get; set; }
|
|
|
|
// SQL Server method to setup concurrency column.
|
|
// [Timestamp]
|
|
// public byte[] Version { get; set; }
|
|
|
|
// SQLite (and other) method to setup concurrency column.
|
|
[ConcurrencyCheck]
|
|
public Guid Version { get; set; }
|
|
}
|