在代码优先方法中将版本系统和表历史记录添加到表中

问题描述 投票:0回答:1

我需要在代码优先方法中使用系统版本属性和SQL的表历史记录,这样,通过使用令牌,当在选择和编辑之间更改记录时,会给出错误并且不保存第二,当员工表中的我的记录发生更改时,会自动在员工历史表中保存一条新记录,通过使用开始日期和结束日期字段,您可以查出该值已经存在了多长时间在主表中。

public class Employee
    {
        public int pk Employee { get; set; }
        public string User Name { get; set; }
        public string Mobile { get; set; }
        public Boolean Mobile Is Active { get; set; }
        public string Email { get; set; }
        public Boolean Email Is Active { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
        public string Password { get; set; }
    }
    public class Employee History
    {
    public int pk Employee { get; set; }
    public string User Name { get; set; }
        public string Mobile { get; set; }
        public Boolean Mobile Is Active { get; set; }
        public string Email { get; set; }
        public Boolean Email Is Active { get; set; }
        public string FirstName { get; set; }
        public string Last Name { get; set; }
    public Date Time StartDate { get; set; }
    public Date Time End Date { get; set; }
        public string Password { get; set; }
    }

c# ef-code-first
1个回答
0
投票

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
    modelBuilder.Entity<Employee>().ToTable("Employee", e => e.IsTemporal());
}

© www.soinside.com 2019 - 2024. All rights reserved.