Hi folks, I've a strange problem using EF1.0... my problem happenin' only during a creation and I didn't find anything on many forum's thread.
> System.InvalidOperationException: The source query for this EntityCollection or EntityReference cannot be returned when the related object is in either an added state or a detached state and was not originally retrieved using the NoTracking merge option. at System.Data.Objects.DataClasses.RelatedEnd.CreateSourceQuery[TEntity](MergeOption mergeOption) at System.Data.Objects.DataClasses.EntityCollection`1.CreateSourceQuery() at Microsoft.Data.EFLazyLoading.LazyEntityCollection`1.CreateSourceQuery() at Microsoft.Data.EFLazyLoading.LazyEntityCollection`1.LoadStubs() at mptradModel.ContextObjects.ChansonWrapper.AttachEntities(Chanson chanson, ChansonRequest request) in (SolutionDir)\ProjectWrapper\ContextObjects\ChansonWrapper.cs:line 115
What is the real problem? I happens when I tried to add an Entity to another entity's list during a command creation.
I.E.: aCommand.Songs.Add(new Song() { Name = "SongName" });
Thank to you guys and sorry for my english ; Im from Quebec and usualy talk french!
UPDATE #1
My line #115 in chansonwrapper (which mean "songwrapper") :
aCommand.Songs.Add(new Song() { Name = "SongName" });
UPDATE #2
Sorry, I were trying to simplify the code to write but I think its just more confusing so here is my real code :
SongWrapper songWrapper = new SongWrapper(this.m_Context);
Song song = songWrapper.Load(request.SongId);
aCommand.Songs.Add(song);
The this.m_Context for my songWrapper ensure that my song returned in in the same context of my "aCommand" or other entity that i could load later/before. This part were alrealy tested so we know it works. One things have changed, is that we moved to "LazyLoading" what we were not using before. More weird, the update works fine! Help meee :oP!