Quantcast
Channel: entityframework Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1793

New Post: Baffled. Model updates, but not the list of items it contains

$
0
0
@Budoray The update method sets the state of "room" to Modified but does not do anything to the state of any related exists. If you are not doing anything other than what is in the code then the state of each Exit object will be in the Unchanged state when you save. This means that EF will not attempt to save anything for the rooms because as far as EF is concerned the objects are all unchanged.

To fix this you will need to set the state of any Exit objects. Exactly what state to set depends on what your application is doing with the Exit objects. For example, if the only thing that can happen is that some existing objects are modified, then just setting all objects to Modified may be fine. This could cause unnecessary updates, but often that is okay. If exits can also be added, then you'll need to know which of the Exit objects are new and set the state of those to Added. One way to do this is to query for existing Exit objects and compare the two lists. Likewise, if Exit objects can be deleted, then you'll need to figure out which have been deleted and set the state appropriately.

This scenario of dealing with disconnected graphs is something we hope to improve in a future version of EF. You may want to vote for this CodePlex item to show your support for doing so: https://entityframework.codeplex.com/workitem/864

Thanks,
Arthur

Viewing all articles
Browse latest Browse all 1793

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>