When working with ADO.NET Entity Data Model, its often common that we generate entity schema for more than a single table from our Database. With Entity Model generation automated by Visual Studio, it becomes even more tempting to create and work with entity models to achieve an object mapping relationship. One of the errors that you might hit while trying to update an entity set either programmatically using context.SaveChanges or while using the automatic insert/update code generated by GridView etc., is “Unable to update the EntitySet because it has a DefiningQuery and no element exists in the element to support the current operation” While the description is pretty lengthy, the immediate thing that would come to our mind is to open our the entity model generated code and see if you can update it accordingly. However, the first thing to check is that, if the Entity Set is generated from a table, whether the table has a primary key definition. Most of the times, we create tables with primary keys. But some reference tables and tables which don’t have a primary key cannot be updated using the context of Entity and hence it would throw this error. Unless it is a View, in which case, the default model is read-only, most of the times the above error occurs since there is no primary key defined in the table.
See original here:
Unable to update the EntitySet because it has a DefiningQuery and no <UpdateFunction> element exists in the <ModificationFunctionMapping>…