小编Jim*_*mes的帖子

使用外键(FK)作为每层次表(TPH)的鉴别器

[问:]是否有可能使用FK作为EF中的鉴别器,人们想出了哪些变通方法?

场景

EF对象

public class List
{
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<ListItem> Items { get; set; }
}

public abstract class ListItem
{
    public int Id { get; set; }
    public List List { get; set; }
    public string Text { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

数据库

EF专用(即无法更改)未使用的现有DB 具有以下字段:

List
    Id         int not null      (identity)
    Name       varchar

ListItem
    Id         int not null      (identity)
    ListId     int not null      (FK to …
Run Code Online (Sandbox Code Playgroud)

sql-server entity-framework-4.1

26
推荐指数
1
解决办法
2399
查看次数

标签 统计

entity-framework-4.1 ×1

sql-server ×1