You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it intended for LazyLoadOnDisposedContextWarning to be thrown when navigational properties are eagerly loaded with .Include()? I know that the warning can be suppressed but in this case, the navigation properties are not lazy-loaded.
The dbContext is registered with .UseLazyLoadingProxies() and the navigation property is accessed after the dbContext is disposed:
//Parent class with virtual ChildNavigationPropertyvaritems= context.ParentClass.Include(x => x.ChildNavigationProperty).ToList();
context.Dispose();//exception thrown here
Console.WriteLine(item.First().ChildNavigationProperty);
On a side note, this exception should also not be thrown for any entities queried using a context with context.ChangeTracker.LazyLoadingEnabled = false; since the navigation properties would just be null.
The text was updated successfully, but these errors were encountered:
Note for triage: the issue here is that once the context is disposed it cannot\should not be used, and this includes using it to determine whether or not a navigation property is loaded. This can be improved as part of #10042 by storing the loaded state in the proxy such that the context does not need to be asked again. However, we're not doing this for 2.1 and I propose we leave the current behavior as is, especially since the warning-error can be turned off.
Is it intended for
LazyLoadOnDisposedContextWarning
to be thrown when navigational properties are eagerly loaded with.Include()
? I know that the warning can be suppressed but in this case, the navigation properties are not lazy-loaded.The dbContext is registered with
.UseLazyLoadingProxies()
and the navigation property is accessed after the dbContext is disposed:On a side note, this exception should also not be thrown for any entities queried using a context with
context.ChangeTracker.LazyLoadingEnabled = false;
since the navigation properties would just be null.The text was updated successfully, but these errors were encountered: