It has a DefiningQuery but no InsertFunction element... err

This thing is driving me crazy, and the error is quite meaningless to me:

Unable to update the EntitySet 'TableB' because it has a DefiningQuery and no element exists in the element to support the current operation.

My tables are put like this:

TableA
int idA (identity, primary key)
...

TableB
int idA (FK for TableA.idA)
int val

TableB has no defined primary key in the SQL server. The Entity Framework has imported the table and the association and set both fields as key. But it will output that error when I try to do an insert into the table!

What's wrong??


Edit: As suggested by Alex, the solution was this:

  1. Right click on the edmx file, select Open with, XML editor
  2. Locate the entity in the edmx:StorageModels element
  3. Remove the DefiningQuery entirely
  4. Rename the store:Schema="dbo" to Schema="dbo" (otherwise, the code will generate an error saying the name is invalid)
  5. Remove the store:Name property

I left the key as it was, since it was OK to me that both the columns are part of the key.


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

It has a DefiningQuery but no InsertFunction element… err, This thing is driving me crazy, and the error is quite meaningless to me: Unable to update the EntitySet 'TableB' because it has a DefiningQuery and no element� Unable to update the EntitySet 'xxxxx' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.


Just Add a primary key to the table. That's it. Problem solved.

ALTER TABLE <TABLE_NAME>
ADD CONSTRAINT <CONSTRAINT_NAME> PRIMARY KEY(<COLUMN_NAME>)

<InsertFunction> element exists in the, it show error: Unable to update the EntitySet 'Student' because it has a DefiningQuery and no <InsertFunction> element exists in the� and get the following error: Unable to update the EntitySet 'UsersLimitationToCountry' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.


I was missing a primary key on my table and got this error message. One thing I noted was after I added the key to the table, I needed to clear the table from the edmx using the designer, save the edmx, then update it again to add the table back in. It wasn't picking up the key since it was already assigned as a view. This didn't require editing the edmx manually.

Unable to update the EntitySet Table because it has a , and getting the following error: " Unable to update the EntitySet Table because it has a DefiningQuery and no InsertFunction element exists in� You have 2 issues there: 1) The most common reason from "Unable to update the EntitySet X because it has a DefiningQuery" is that entity table missing a primary key constraint in database. You can add primary key to identity column either by SSMS table designer or using this query (note that primary key should be only set to one column):


Add primary key to table, delete the model from the edmx model, then select update from database, build and run...... works

Unable to update the EntitySet because it has a DefiningQuery and , but getting this error Unable to update the EntitySet because it has a it has a DefiningQuery and no <InsertFunction> element exists in the� It has a DefiningQuery but no InsertFunction element… err SqlException from Entity Framework-New transaction is not allowed because there are other threads running in the session Unable to update the EntitySet 'ItemRankList' because it has a DefiningQuery and no<UpdateFunction> element exists


@Palantir. Verify that both of you tables have Primary Keys set, and be careful with multiple primary keys set in a table.

Entity Framework Error on SaveChanges(), Unable to update the EntitySet - because it has a DefiningQuery and no < UpdateFunction> element exists in the <ModificationFunctionMapping>� Unable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. I have been recently facing an issue while saving data in one of the table using Entity Framework. an exception occurred on the line DBEntities.SaveChanges() and it


because it has a DefiningQuery and no <InsertFunction> element , When you get error. 'Unable to update the EntitySet 'xxxxxxxx' because it has a DefiningQuery and no <InsertFunction> element exists in the� Unable to update the EntitySet 'UserDetails' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. Description: An unhandled exception occurred during the execution of the current web request.


Unable to update the EntitySet 'table' because it has DefiningQuery , In this tutorial i will show how to resolve the error "Unable to update the EntitySet because it Duration: 3:17 Posted: Feb 19, 2019 Unable to update the EntitySet 'current_academic' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. I have Written action code as below


T367659, it gave me an error : "Unable to update the EntitySet 'Employee' because it has a DefiningQuery and no <InsertFunction> element exists in� While submitting a create with some values in a page then it will through this error. Unable to update the EntitySet Table because it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current operation. Software Engineer.