Query Include Optimized Not Working When I Use AsNoTracking() Method
Hi, When i use IncludeOptimized with AsNoTracking() it's not data appears.
var currentModel = db.Users.AsNoTracking() .IncludeOptimized(x=>x.Group) .FirstOrDefault(x=>x.Id == id);
From the above code not working (no "Group" data appears), but if remove AsNoTracking() is working.
Thanks and Regards, Bahar
Hello @bdjema,
Thank you for reporting.
That is a well-known limitation of our library that we should work on. We already started this fix, I will check during the weekend on much time is left to complete it.
Best Regards,
Jonathan
Hi @JonathanMagnan just wondering if that fix ever materialised for this issue? Thanks!
Hello @GFoley83 ,
Unfortunately no, we have run into some problem last time we tried.
We are currently focusing our time on the free support on thing such as Fiddle to allow to share only Entity Framework example online: http://www.zzzprojects.com/roadmap
We will probably try again to fix this issue later this year but we have no short time plan for now.
Best Regards,
Jonathan
Hi! Is this issue still present ?
Yes @marcbernal
Looks like this is still an issue more than 4 years after the first report?
Hello @bartvanandel ,
Yes, unfortunately, this feature uses the ChangeTracker to set the reference and the AsNoTracking makes it not compatible.
The only way to fix it is either on our side to create a new context internally to handle it automatically (so we will keep tracking entities but simply in a context that will be disposed of right after), or you do the same with a context that you dispose of after.
Thanks for your prompt response!
Currently I've just disabled the .AsNoTracking() calls in our code with a note about incompatibility. For us it's not really a performance penalty at this stage anyway.
The disposable tracker sounds like a promising approach though, especially when provided by the library (less local customization required).
Hi, any chance of this being addressed?