我有这种情况:
var customer = unitOfWork.Customers.FirstOrDefault(c => c.Id == 1); // existing customer
var certificate = unitOfWork.Certificates.FirstOrDefault(c => c.Id == 1); // existing certificate
certificate.Customer = customer;
unitOfWork.SaveChanges();
结果是没有更新发生。当我检查时,ChangeTracker.Entities
我看到我的证书已设置给客户。但我也看到这State
是Unchanged
......这怎么可能?我给变量一个值(certificate.Customer = customer;
)并且没有发生任何变化?
我在这里想念什么?