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
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?
Comments
Steve
#
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.
Relieved
#
Thank you so much! I had been freaking out for days with the same error... now it works :)
Andrew
#
Thanks for this, had the same issue and although my model had a Key, the table didn't.