Dailycode.info

Short solution for short problems

Unable to update the EntitySet '' because ...

Got this error using the entity framework and self-tranking entities:

Unable to update the EntitySet 'MyEntity' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

Couldn't find the problem at first, even google didn't really gave me any thoughts. Untill I noticed that I forgot to set a primary key in the database table. Problem solved. Or so I thought.

Apparently Visual studio created a key itself on the edmx model, off course the wrong one. After a update from database, the model added the correct key, but didn't removed the key which it had created itself. So I removed it myself, then did an updated the model again from the database.