As @NicholasButler said, calling SaveChanges does what it says on the gesture - you can see it if you debug your code: the Intellitrace output will show the SQL that it generated for the insert / update that you save, but there will be no further selection.
Keep in mind that if you do not want to download (using the Include method), related objects are not loaded when performing a search, so it is quite reasonable that they will not be created and updated either.
Entity Framework (since version 4.1 and higher) supports lazy loading. This means that if it is enabled, a code of type Client c1 = entity.Client; should load this Client object. To be clear, this operation is not directly related to calling SaveChanges .
Pays to check if db.Configuration.LazyLoadingEnabled is db.Configuration.LazyLoadingEnabled to true . If not, try setting it to true and see if Client c1 = entity.Client; remains Client c1 = entity.Client; null
In short, calling SaveChanges does not cause loading, but if lazy loading is enabled, access to entity.Client should initiate loading of the object if it has not already been loaded.
Edit:
I should have even talked about this before, but you wonโt get the lazy load on your Survey entity . The reason is that EF works with lazy loading magic, creating a class derived from yours, but overriding properties marked as virtual to support lazy loading. It does this when you do a search, so your entity will not be too lazy to load whatever it is.
Try this right after your call to SaveChanges :
Survey entity2 = db.Surveys.Find(entity.ID); Client c1 = entity2.Client;
This should be the behavior that you are after.
nick_w Mar 27 '13 at 9:42 on 2013-03-27 09:42
source share