简体   繁体   中英

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 . 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;}
}   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM