This content has moved - please find it at https://devblog.cyotek.com.

Although these pages remain accessible, some content may not display correctly in future as the new blog evolves.

Visit https://devblog.cyotek.com.

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

After integrating the new forum code, I added basic subscription support. When replying to a topic and opting to subscribe to notifications, the following exception would be thrown:

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

I'd already checked the Entity model to ensure the relationships were set up correctly as a many to many, as one user may be subscribed to many threads, and any given thread can have many subscribed users, so I was a little perplexed as to where this was coming from.

After looking at the database table which links threads and users, I realized the problem was the table didn't have a unique key, only the relationships. After creating a primary key on the two columns in this table, and regenerating the Entity model, the exception disappeared and subscriptions are now working as expected.

It's always the little things...

Update History

  • 2010-03-26 - First published
  • 2020-11-21 - Updated formatting

About The Author

Gravatar

The founder of Cyotek, Richard enjoys creating new blog content for the site. Much more though, he likes to develop programs, and can often found writing reams of code. A long term gamer, he has aspirations in one day creating an epic video game. Until that time, he is mostly content with adding new bugs to WebCopy and the other Cyotek products.

Leave a Comment

While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?

Styling with Markdown is supported

Comments

Gravatar

Steve

# Reply

Thanks. Yes it's always the little thing. I almost scrapped off my scalp today until I came across this. I forgot to set a primary key on a table and then the exact same error over and over again.

Thanks for writing ur experience.

Gravatar

Relieved

# Reply

Thank you so much! I had been freaking out for days with the same error... now it works :)

Andrew

# Reply

Thanks for this, had the same issue and although my model had a Key, the table didn't.