Share Coding

Tutorials, Problems, Stuffs …

Entity Framework Update table without primary Key

Exception throw when try to call DBModel.SaveChanges()

System.Data.Entity.Infrastructure.DbUpdateException: Unable to update the EntitySet ‘role_app_right’ because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation. —> System.Data.Entity.Core.UpdateException: Unable to update the EntitySet ‘role_app_right’ because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.

  1. Right click on the edmx file, select Open with… > XML Text editor
  2. Find the EntitySet in edmx:StorageModels > EntityContainer
  3. Remove the DefiningQuery entirely
  4. Rename [store:Schema=”dbo”] to [Schema=”dbo”]

123

<EntitySet Name=“role_app_right” EntityType=“Self.role_app_right” store:Type=“Tables” Schema=“dbo” />

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: