具有Entity Framework Core的不同dbcontext中的表的外键

时间:2018-04-09 19:27:49

标签: c# entity-framework-core

如何向具有Entity Framework Core的其他DbContext中的表添加外键引用?

class DonationContext : DbContext
{
    public decimal Amount { get; set; }
    public string DonationType { get; set; }
    public string Desc { get; set; }
    public int? ChackID { get; set; }
    public Check Check { get; set; }
    public int? DonorCreditCardID { get; set; }
    public DonorCreditCard DonorCreditCard { get; set; }
    public string fundraisedBy;
    [NotMapped]
    public string FundraisedBy
}

public class DonorContext : DbContext
{
    public DbSet<DonorCreditCard> DonorCreditCards { get; set; }
    public DbSet<DonorAddress> DonorAddresss { get; set; }
    public DbSet<DonorPhoneNumber> DonorPhoneNumbers { get; set; }
    public DbSet<DonorEmailAddress> DonorEmails { get; set; }
    public DbSet<DonorFileAttachment> DonorFileAttachments { get; set; }
    public DbSet<Donor> Donors { get; set; }
}

我想将DonorCreditCardID中的DonationContext列引用到DonorCreditCards中的DonorContext表格。迁移构建器想要创建新表DonorCreditCards

0 个答案:

没有答案