我正在使用带有graphdiff和EDMX的EF6,并且必须忽略特定实体的属性。
我该怎么办,因为即使获取属性插入或更新总是留下NULL字段?
答案 0 :(得分:5)
我能够解决这个问题的方式,同时仍然受益于GraphDiff的简易性如下:
(例子)
user = db.UpdateGraph(user, map => map
.AssociatedCollection(u => u.UserRoles)
.AssociatedCollection(u => u.Teams));
db.Entry(user).Property(u => u.Password).IsModified = false;
db.Entry(user).Property(u => u.Salt).IsModified = false;
_context.SaveChanges();