【问题标题】:TPT mapping Entity Framework CTP4 behaving like TPHTPT 映射实体框架 CTP4 的行为类似于 TPH
【发布时间】:2010-10-31 07:17:31
【问题描述】:

我正在按照建议编写代码,

public class A 
{
    public int id {get;set;}
    public string Astring {get;set;}
}

public class B : A
{
    public string Bstring {get;set;}
}

builder.Entity<A>().MapHierarchy( u=> new { ... }).ToTable("A");
builder.Entity<B>().MapHierarchy( u=> new { ... }).ToTable("B");

... = 我有提到的所有属性和 u.Id。

我也有DbSet&lt;A&gt; A {get;set;}DbSet&lt;B&gt; B {get;set;}ObjectSet 在我使用模型构建器时的属性

builder.Entity<A>
builder.Entity<B>

这会导致创建的表 A 带有一个鉴别器列和 Id、Astring、Bstring。这是默认的 TPH 映射,不知道为什么会这样。 谢谢

【问题讨论】:

  • 我认为这个问题的标题是正确的,不应该从 TPT 更改为 TPH,因为正如提问者所说,他正在寻找 TPT 行为但从 EF 获取 TPH。

标签: c# entity-framework-4 code-first


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多