using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace VCommon.VEntity
{
    public abstract class VEntityBase
    {
        private Guid? _keyField; //EF Core Trick? must difference with prop name for init

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.None)]
        public Guid Id
        {
            get => _keyField ??= Guid.NewGuid();
            set => _keyField = value;
        }
    }
}