0
我有這樣的代碼保存一個簡單的實體:實體框架 - 上的SaveChanges異常
ExecutionEngineEntities db = new ExecutionEngineEntities();
Task task = new Task();
task.Message = "Test";
task.Result = "Test";
task.Name = "Test";
db.Tasks.AddObject(task);
db.SaveChanges();
這是例外:
A first chance exception of type 'System.Data.UpdateException' occurred in System.Data.Entity.dll
Unable to update the EntitySet 'Tasks' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
The program '[6092] WebDev.WebServer40.EXE: Managed (v4.0.30319)' has exited with code 0 (0x0).
這是創建表的代碼:
CREATE TABLE [dbo].[Tasks](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nchar](50) NULL,
[Message] [nchar](1000) NULL,
[Result] [nchar](1000) NULL
) ON [PRIMARY]
在谷歌搜索後,我發現模式的人有這個錯誤有關係問題,噸他不是我的情況下
感謝
謝謝,答案幫助了我,但我創建了一個表格,而不是視圖....出了什麼問題,我如何讓EF將它看作是表格而不是視圖? – SexyMF
在我已鏈接的答案有另一個鏈接:http://blogs.msdn.com/b/alexj/archive/2009/09/01/tip-34-how-to-work-with-updatable-views .aspx,它告訴你如何檢查它是否配置爲模型中的表或視圖 – Andreas