//
you're reading...
Software Development, Web Development

Entity Framework with no Primary Key: Shame on you!


if you run into the following error using Entity Framework:

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

It’s likely because you haven’t set a primary key in your database and/or edmx

Sometimes I feel tables (join tables) don’t need primary keys but it seems wise to just bite the bullet and add it for EF sake.  Though for a join table you could simply delete/insert instead of updating it and forgo the key.

Solution is to add the primary key and then remove the table from your edmx.  Then right click and” update model from database …”

Done and done!

Advertisements

Discussion

One thought on “Entity Framework with no Primary Key: Shame on you!

  1. Hope this helps

    1.Change the Table structure and add a Primary Column. Update the Model.

    2.Modify the .EDMX file in XML Editor and try adding a New Column under tag for this specific table. (WILL NOT WORK)

    3.Instead of creating a new Primary Column to Exiting table, i will make a composite key by involving all the existing columns.(WORKED)

    Entity Framework: Adding DataTable with no Primary Key to Entity Model.

    Posted by Pratap | April 29, 2012, 2:26 pm

Leave a Reply

Fill in your details below or click an icon to log in:

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