如何解决实体框架代码第一个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
类型。我正在尝试遵循这样的方案。如果可以,我希望可以继承它,例如:
public class PaymentCheque : Payment
{
public int RoutingNumber {get; set;}
}
解决方法
您可以查看以下三篇文章,重点介绍如何在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/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和选择策略准则
,您确实尝试过吗?还是搜索/搜索它?
参见: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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。