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
. 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:
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With