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...
All content Copyright (c) by Cyotek Ltd or its respective writers. Permission to reproduce news and web log entries and other RSS feed content in unmodified form without notice is granted provided they are not used to endorse or promote any products or opinions (other than what was expressed by the author) and without taking them out of context. Written permission from the copyright owner must be obtained for everything else.
Original URL of this content is https://www.cyotek.com/blog/unable-to-update-the-entityset-because-it-has-a-definingquery-and-no-element-exists-in-the-element-to-support-the-current-operation?source=rss.