Page 1 of 1
The EntitySet is already loaded and the source cannot be
Posted: Wed 22 Jul 2009 02:16
by andrewjco
Hi,
I get an exception when trying to re-attach entities to a context.
"The EntitySet is already loaded and the source cannot be changed."
I'm trying to figure out under what circumstances this message will be fired?
Posted: Wed 22 Jul 2009 11:26
by AndreyR
Could you please post the code you are using to re-attach an entity?
Posted: Thu 23 Jul 2009 03:51
by andrewjco
Not easily unfortunately, although I could try and whip up a sample project.
There seems to be very little info on google for this error, so I was more interested if you guys could tell me why it might fire.
Posted: Fri 24 Jul 2009 10:48
by AndreyR
Could you please post the call stack of the error here?
It should clarify the problem.
Incorrect SetSource method usage could also be a reason if this problem.
Call Stack
Posted: Sat 19 Sep 2009 13:42
by Nahmis
We're also seeing this behavior since latest release, here's the callstack that blows up after a call to:
Code: Select all
DataContext.GetTable().Attach(OurUpdatedObjectFromTheSameContext, true);
Code: Select all
[InvalidOperationException: The EntitySet is already loaded and the source cannot be changed.]
System.Data.Linq.EntitySet`1.SetSource(IEnumerable`1 entitySource) +807755
Devart.Data.Linq.Mapping.EntitySetDefSourceAccessor`2.a(T& A_0, IEnumerable`1 A_1) +104
System.Data.Linq.Mapping.MetaAccessor`2.SetBoxedValue(Object& instance, Object value) +84
Devart.Data.Linq.Provider.d.SetLinks(TEntity obj, Object keySource, IList`1 linkMembers, EntityCache`2 cache, f services, IList`1 queryLoadWith, Dictionary`2 nextLoadWiths) +1154
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +71
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +261
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
Devart.Data.Linq.Table`1.a(TEntity A_0, TEntity A_1, Boolean A_2) +691
Devart.Data.Linq.Table`1.Attach(TEntity entity, Boolean asModified) +13
Posted: Mon 21 Sep 2009 14:26
by AndreyR
Thank you for the report, we are investigating the problem.
I will let you know about the results.
Posted: Tue 06 Oct 2009 13:16
by AndreyR
We have fixed the problem. Look forward to the next build.