27 May 2014

Entity Frameword 6 Error: Unable to update the EntitySet 'X' because it has a DefiningQuery and no element exists in the element to support the current operation.

I was inserting an object in entity framework 6 using the usual code:
context.X.Add(x); context.SaveChanges();
The entity framework returned the error:
Unable to update the EntitySet 'X'because it has a DefiningQuery and no element exists in the element to support the current operation.

The solution to fix this error was to create a primary key in the table and update the entity model.

No comments: