[英]Entity Framework Code First 0 to 1 mapping
I want to create a map of these 2 models, how do I do this in code-first? 我想创建这两个模型的地图,我该如何在代码优先?
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
can be either of type PaymentBank
or PaymentCheque
. Payment
可以是PaymentBank
或PaymentCheque
。 I'm trying to follow a scenario like this . 我试图按照类似的情景这样 。 I'd love if I could do inheritance of this if possible, such as: 如果可能的话,如果我可以继承这个,我会很高兴,例如:
public class PaymentCheque : Payment
{
public int RoutingNumber {get; set;}
}
You can check out the following three articles which focus on implementing inheritance in Entity Framework Code-First: 您可以查看以下三篇专注于在Entity Framework Code-First中实现继承的文章:
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/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/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 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-和选择策略,guidelines.aspx
Did you actualy try it? 你真的尝试过吗? Or search/google for it? 或搜索/谷歌吗?
see: 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/24/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-1-table-per-hierarchy- tph.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.