How to Update the Entityset - Because It Has a Definingquery and No <Updatefunction> Element Exist

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:

  1. And convince the EF that what it thinks is a view is really a table
  2. Or add the appropriate modification functions

In your case I recommend (1).



Related Topics



Leave a reply



Submit