【问题标题】:Entity Framework Code First 0 to 1 mapping实体框架代码优先 0 到 1 映射
【发布时间】:2011-04-18 05:37:28
【问题描述】:

我想创建这 2 个模型的地图,如何在代码优先中执行此操作?

public class Payment
{
    public int PaymentId { get; set; }
}

public class PaymentBank
{
    public int PaymentId { get; set; }
}

public class PaymentCheque
{
    public int PaymentId { get; set; }
}

Payment 可以是PaymentBankPaymentCheque 类型之一。我正在尝试遵循this 之类的场景。如果可能的话,我很乐意继承它,例如:

public class PaymentCheque : Payment
{
    public int RoutingNumber {get; set;}
}   

【问题讨论】:

  • 先查看这篇关于代码继承的文章:link
  • 顺便说一句。如果您不打算添加任何其他付款类型,我建议您使用 TPH 策略,因为其他策略的性能较差。
  • @Ladislav,当客户要求更多付款选项时,我想添加更多内容。这是否意味着我应该使用 TPC?
  • 我喜欢每个层级的 1 个表,它似乎在我的情况下会很好用。 TPC 还有哪些其他场景有意义?

标签: c# .net ef-code-first entity-framework-4.1


【解决方案1】:
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 2011-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-12
  • 2011-04-21
相关资源
最近更新 更多