0

I have this code saving a simple Entity:

ExecutionEngineEntities db = new ExecutionEngineEntities();
Task task = new Task();
task.Message = "Test";
task.Result = "Test";
task.Name = "Test";
db.Tasks.AddObject(task);
db.SaveChanges();

This is the exception:

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).

This is the create table code:

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]

After searching in google I found that mode people who got this error has a relation problems, this is not my case

Thanks

1 Answer 1

2

Maybe the answer here can help you: It has a DefiningQuery but no InsertFunction element... err

It could be that in the EF model it is configured that this entity is a view and not a table. Views don't support create, update or delete operations, so you can't insert.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, the answer helped me, but I have created a table not a view.... What went wrong, how do i make EF to see it as an table and not a view?
In the answer that I have linked there is another link: blogs.msdn.com/b/alexj/archive/2009/09/01/… which tells you how to check if it's configured as a table or a view in the model

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.