Cyotek Development Bloghttps://devblog.cyotek.com/tag/sql-server/atom.xml2012-01-24T16:52:01ZUnable to update the EntitySet because it has a DefiningQuery and no element exists in the element to support the current operation.urn:uuid:3154493f-a9b1-4f94-968d-955487a4ac392012-01-24T16:52:01Z2010-03-26T19:59:11Z<p>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:</p>
<blockquote>
<p>Unable to update the EntitySet 'ThreadSubscriptions' because
it has a DefiningQuery and no element exists in the element
to support the current operation.</p>
</blockquote>
<p>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.</p>
<p>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.</p>
<p>It's always the little things...</p>
<h2 id="update-history">Update History</h2>
<ul>
<li>2010-03-26 - First published</li>
<li>2020-11-21 - Updated formatting</li>
</ul>

<p><small>
All content <a href="https://devblog.cyotek.com/copyright-and-trademarks">Copyright (c) by Cyotek Ltd</a> 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.<br />Original URL of this content is https://devblog.cyotek.com/post/unable-to-update-the-entityset-because-it-has-a-definingquery-and-no-element-exists-in-the-element-to-support-the-current-operation .
</small></p>Richard Mosshttps://www.cyotek.com/richard.moss@cyotek.com