2014-02-17 65 views
1

完全错误是:实体框架6错误:无法更新EntitySet的“表1”

Unable to update the EntitySet 'table1' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation 

环视,似乎这个错误是由于缺乏对table1主键造成的。我检查了我的.edmx文件和SQL服务器中的表,并且都显示指定了主键。我还应该看什么?

+0

如何显示一些代码?应该看看http://social.msdn.microsoft.com/Forums/en-US/220262bd-85d4-4f29-96a8-4a7d1d2c8293/unable-to-update-the-entityset-because-it-hasa-a- definingquery-和无deletefunction元素?论坛= adodotnetentityframework – Miller

回答

1

如果您使用的是edmx,则会为数据库视图定义DefiningQuery,EF会将从视图创建的EntitySet视为只读。如果您希望能够操作数据,则需要映射将用于CUD(创建/更新/删除)操作的存储过程。