实体框架代码第一个0到1的映射
我想创建这两个模型的地图,我该如何在代码优先?实体框架代码第一个0到1的映射
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
可以是PaymentBank
型或PaymentCheque
的。我试图按照如this的方案。如果可以的话,我愿意继承,如:
public class PaymentCheque : Payment
{
public int RoutingNumber {get; set;}
}
您可以检查出其专注于实体框架代码优先实现继承以下三篇文章:
http://weblogs.asp.net/manavi/archive/2010/12/24/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-1-table-per-hierarchy-tph.aspx
http://weblogs.asp.net/manavi/archive/2010/12/28/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-2-table-per-type-tpt.aspx
http://weblogs.asp.net/manavi/archive/2011/01/03/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-3-table-per-concrete-type-tpc-and-choosing-strategy-guidelines.aspx
你真的试过吗?或搜索/谷歌呢?
那是反复的,对吧? :-) – 2011-04-18 13:16:02
检查这篇文章中的代码继承第一:[链接](http://weblogs.asp.net/manavi/archive/2010/12/24/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-1-table- per-hierarchy-tph.aspx) – Damb 2011-04-18 05:50:04
顺便说一句。如果您不打算添加任何其他支付类型,我会建议使用TPH策略,因为其他策略的性能更差。 – 2011-04-18 21:22:58
@Ladislav,我想添加更多的客户端请求更多付款选项。这是否意味着我应该使用TPC? – 2011-04-18 22:32:19