Unable to update the EntitySet - because it has a DefiningQuery and no UpdateFunction element exist
It usually happens because one of the following reasons:
- Entity Set is mapped from Database view
- A custom Database query
- Database table doesn't have a primary key
After doing so, you may still need to update in the Entity Framework designer (or alternatively delete the entity and then add it) before you stop getting the error.
because it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element
My many-to-many mapping table was missing PK
added, and the issue is solved.
Unable to update the EntitySet 'ItemRankList' because it has a DefiningQuery and no UpdateFunction element exists
Guess i should also ask the context... how are you using linq?
Do you have a primary key defined on the table ?
If not add the key and update the EF model.
Unable to update the EntitySet '...' because it has a DefiningQuery
Update your database, set pair of foreign key to tables in m2m table as primary key.
Then update your model to database.
Why am I getting a Unable to update the EntitySet because it has a DefiningQuery... exception when trying to update a model in Entity Framework?
The problem was in the table structure. To avoid the error we have to make one primary key in the table. After that, update the edmx. The problem will be fixed
It has a DefiningQuery but no InsertFunction element... err
Well when a table is encountered without a PrimaryKey it is treated as a View.
And views show up in the EDMX file (open in an XML editor to see) in the StorageModel\EntitySet[n]\DefiningQuery element.
When you have a DefiningQuery the Entity becomes readonly unless you add modification functions. You need 3 modifications functions (aka Stored Procedures) one for each of Insert, Update and Delete.
But you have two options:
Change the key definion:
- And convince the EF that what it thinks is a view is really a table
- Or add the appropriate modification functions
In your case I recommend (1).
Related Topics
Is There a Reason Image.Fromfile Throws an Outofmemoryexception for an Invalid Image Format
Is There a Jquery-Like CSS/HTML Selector That Can Be Used in C#
Nullable Type as a Generic Parameter Possible
How to Get Variable Name Using Reflection
Why Use Icollection and Not Ienumerable or List<T> on Many-Many/One-Many Relationships
Programmatically Add Column & Rows to Wpf Datagrid
How to Programmatically Fill in a Form and 'Post' a Web Page
How to Use the Paint Event to Draw Shapes at Mouse Coordinates
Reference Assignment Is Atomic So Why Is Interlocked.Exchange(Ref Object, Object) Needed
C#: List All Classes in Assembly
An Object Reference Is Required to Access Non-Static Member
Handle Modelstate Validation in ASP.NET Web API
Recursively Get Properties & Child Properties of a Class
Metadata File '.Dll' Could Not Be Found
How to Hide Only the Close (X) Button
Is Task.Run Considered Bad Practice in an Asp .Net MVC Web Application