我正在为我的角度应用程序在后端工作,但是我错过了数据库中的表MoneyTransfers
和FixedMoneyTransfers
。
此问题的相关实体是BankAccount
,CostCentre
和MoneyTransfer
BankAccount
具有两个List<MoneyTransfer>
类型的独立属性(TransferReceipts和TransferDebits)以及一个List<FixedMoneyTransfer>
。
CostCentre
具有List<MoneyTransfer>
类型的两个单独的属性(BudgetReceipt和BudgetDebits)。
最后MoneyTransfer
有两个单独的BankAccounts
(源,目标)和两个单独的CostCentres
(源,目标)。 FixedMoneyTransfer
也是如此。
EF是否很难在数据库中表示这些关系?我应该更改数据模型吗?
预先感谢
请参阅以下相关文件:
DbContext:
public class AccountBookDbContext : DbContext
{
public DbSet<Depositor> Depositors { get; set; }
public DbSet<BankAccount> BankAccounts { get; set; }
public DbSet<CostCentre> CostCentres { get; set; }
public AccountBookDbContext(DbContextOptions<AccountBookDbContext> options) : base(options) { }
}
BankAccount.cs:
public class BankAccount
{
public int Id { get; set; }
public Depositor Depositor { get; set; }
public List<MoneyTransfer> TransferReceipts { get; set; }
public List<MoneyTransfer> TransferDebits { get; set; }
//other properties not shown
}
CostCentre.cs:
public class CostCentre
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<MoneyTransfer> BudgetReceipts { get; set; }
public List<MoneyTransfer> BudgetDebits { get; set; }
}
MoneyTransfer.cs:
public class MoneyTransfer
{
public int Id { get; set; }
public DateTime Date { get; set; }
public BankAccount SourceAccount { get; set; }
public CostCentre SourceCostCentre { get; set; }
public BankAccount TargetAccount { get; set; }
public CostCentre TargetCostCentre { get; set; }
public double Figure { get; set; }
public string Reference { get; set; }
}
FixedMoneyTransfer.cs:
public class FixedMoneyTransfer
{
public int Id { get; set; }
public BankAccount SourceAccount { get; set; }
public CostCentre SourceCostCentre { get; set; }
public BankAccount TargetAccount { get; set; }
public CostCentre TargetCostCentre { get; set; }
public string Reference { get; set; }
public double Figure { get; set; }
public int Frequency { get; set; }
public DateTime DueDate { get; set; }
}