如何向具有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