假设我们有:
public class Driver
{
public int driverID { get; set; }
public byte[] stamp { get; set; }
public string name { get; set; }
public string prename { get; set; }
}
现在简而言之,我正面临这种情况。
...
var myDriver = myCustomDBContext.Drivers.AsNoTracking()
.Where(d => d.driverID == driverID)
.SingleOrDefault();
...
myDriver.name = "John";
myDriver.prename = "Lennon";
...
myCustomDBContext.Drivers.Attach(myDriver);
myCustomDBContext.Entry(myDriver).State = EntityState.Modified;
myCustomDBContext.SaveChanges();
...
结果是
The column cannot be modified because it is an identity, rowversion or
a system column. [Column name = stamp]
是否有任何方法可以强制对分离的实体进行更新,或者没有将此rowversion列设置为已修改的解决方法。