Table per Hierarchy Inheritance 建模

1.让我们假设你有如图8-1中的表,Employee表包含hourly employees 和salaried employees的行。列EmployeeType作为鉴别列,鉴别这两种员工类型的行。 当EmployeType为1时,这一行代表一个专职员工(salaried or full-time employee),当值为2时,这一行代码一个钟点工(hourly employee).

entityframework学习笔记--008-实体数据建模基础之继承关系映射TPH

 

图8-1

2.右键你的项目,添加上图中的poco实体。如下:

[Table("Employee", Schema = "example8")]
    public abstract class Employee
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int EmployeeId { get; protected set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
Employee

相关文章:

  • 2021-08-04
  • 2021-12-13
  • 2021-07-29
  • 2021-09-29
  • 2021-11-27
  • 2021-08-23
  • 2021-12-06
  • 2021-12-08
猜你喜欢
  • 2021-11-24
  • 2021-07-24
  • 2021-07-02
  • 2022-12-23
  • 2021-08-31
  • 2021-09-26
  • 2021-07-06
相关资源
相似解决方案