【发布时间】:2016-06-16 15:30:40
【问题描述】:
我有两个想要使用 EF6 fluent API 配置的数据库实体。
public class Account
{
public Int32 Id { get; set; }
public Int32? LastOperationId { get; set; }
public virtual Operation LastOperation { get; set; }
public virtual List<Operation> Operations { get; set; }
}
public class Operation
{
public Int32 Id { get; set; }
public Int32? AccountId { get; set; }
public virtual Account Account { get; set; }
}
对于任何配置,在尝试将帐户实体实例插入数据库时,我总是会收到错误“无法确定相关操作的有效排序”:
var account = new Account();
var operation = new Operation();
account.Operations = new List<Operation>() { operation };
account.LastOperation = operation;
dbContext.Accounts.Add(account);
dbContext.SaveChanges();
【问题讨论】:
标签: c# sql .net entity-framework