更新时间:2023-02-17 08:07:39
在大多数情况下,EF会自动检测哪些字段需要更新,并且在上下文中(带有实体)具有update
函数是对说您正在尝试做不必要的事情.
In most cases, EF will automatically detect which fields need updating, having an update
function in a context (that takes an entity) is a red flag to say you are trying to do something that is not required.
EF在幕后做了很多事情,因此您不必考虑它们.这就是其中之一.
EF does a lot of things behind the scenes, so you don't have to think about them. This is one of them.
我怀疑您读了一个非常老的博客,内容涉及10年前某人必须如何做才能使EF更新记录.
I suspect you read a really old blog about how someone 10 years ago had to do something to get EF to update a record.
此外,从上下文类中删除该update
函数,以便没有其他人绊倒它.
Also, remove that update
function from your context class, so that no-one else trips up on it.