//
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!

Advertisement

Discussion

No comments yet.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.