0
我碰到一个很奇怪的场景来了,我有这个模型(客户)我的EDMX内部文件更新表字段使用EF数据库首先usind EDMX
public int ID { get; set; }
public string CompanyName { get; set; }
public string PhoneNo { get; set; }
public string FaxNo { get; set; }
public string CustomerNo { get; set; }
public Nullable<System.DateTime> Modified { get; set; }
public System.DateTime Created { get; set; }
public Nullable<int> PMFormID { get; set; }
public Nullable<int> InspectionFormID { get; set; }
public Nullable<int> RepairFormID { get; set; }
public string Email { get; set; }
现在,当我尝试更新此`
Customer customerToUpdate = _context.Customers.Where(c => c.ID == customer.ID).SingleOrDefault();
customerToUpdate.CompanyName = customer.CompanyName;
customerToUpdate.CustomerNo = customer.CustomerNo;
customerToUpdate.PhoneNo = customer.PhoneNo;
customerToUpdate.FaxNo = customer.FaxNo;
customerToUpdate.Modified = DateTime.Now;
customerToUpdate.InspectionFormID = customer.InspectionFormID;
customerToUpdate.PMFormID = customer.PMFormID;
customerToUpdate.RepairFormID = customer.RepairFormID;
customerToUpdate.Email = customer.Email;
context.SaveChanges();
除修改字段外,所有字段都已更新。它的Tha值仍然为空。哪里不对?请帮忙
'modified'(每个数据库)的列类型是什么? –
列类型是DateTime,我对其他实体做了同样的处理,但它的工作原理令人沮丧,因此在这个实体中它不起作用。也许有些问题我从来不知道。我使用EF数据库第一种方法使用EDMX(拖放一个)。 – user2457699
它可以在数据库中为空吗? –