属性“文本”是对象的关键信息的一部分,不能修改 [英] The property 'text' is part of the object's key information and cannot be modified
问题描述
所以我有一个表在数据库中,一列只是一个nvarchar(800)。
So I have a table in the database, with a column that is simply an nvarchar(800).
当我尝试做:
try
{
UserTable = (from x in entities.userTable where x.uID == uID select x).Single();
UserTable.DateCreated = DateTime.Now;
UserTable.text= newText;
Update(UserTable);
}
我在catch中收到异常:属性'text'是对象的关键信息的一部分,无法修改。
I get the exception in catch: "The property 'text' is part of the object's key information and cannot be modified."
当我看着表格时,我看不到钥匙或索引下的任何东西。所以这不是一个关键,我不明白为什么C#给我不正确的信息。 SQL Management Studio中没有任何关于文本是关键或索引的内容。我该怎么办?
When I look into the table, I don't see anything under "key" or "index". So it's not a key, I don't understand why C# is giving me incorrect information. Nothing in SQL Management Studio says anything about "text" being a key or index. What do I do?
推荐答案
桌上有PK吗?如果不是,EF将使用所有的字段/列作为密钥信息的一部分。
Is there a PK on the table at all? If not, EF uses all of the fields/columns as part of the "key information."
这篇关于属性“文本”是对象的关键信息的一部分,不能修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!