我需要在代码优先方法中使用系统版本属性和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; }
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Employee>().ToTable("Employee", e => e.IsTemporal());
}