我有两个看起来像这样的实体:
public class Account
{
public int AccountId { get; set; }
public string AccountName { get; set; }
public decimal AccountBalance { get; set; }
public virtual Expense Expense { get; set;}
}
public class Expense
{
public int ExpenseId { get; set; }
public string ExpenseName { get; set; }
public decimal ExpenseAmount { get; set; }
public virtual ICollection Accounts { get; }
}
如果我想要一个新添加Expense到DbContext.Expenses与Account已经存储中的对象Database,做我还需要这个新添加Expense到Account Entity?
在我的测试中Expenses,Account Model如果我只是创建一个新Expense实体,则无法从访问关联。
相关分类