Closed as not planned
Description
I have a query, where I need to Include Multiple Navigation properties, that exist on the same level.
E.g. it can be done like so:
(the query is simplified to reflect only the problem)
var targetQuestion = await context.TemplateQuestions
.Include(q => q.Category)
.ThenInclude(c => c.Template)
.ThenInclude(t => t.Categories)
.Include(q => q.Category)
.ThenInclude(c => c.Questions)
.AsNoTracking()
.SingleAsync(q => q.Id == question.Id);
Or rewritten like so:
var targetQuestion = await context.TemplateQuestions
.Include(q => q.Category.Questions)
.Include(c => c.Category.Template.Categories)
.AsNoTracking()
.SingleAsync(q => q.Id == question.Id);
Details:
- My Context is set up as Scoped/Per-Request, not Transient.
- As the Context is Scoped, I do need AsNoTracking() here in order to get the updates, that were performed on that instance.
In the current , 3.0 version of the Ef Core I started to get the following exception:
System.InvalidOperationException : The Include path 'Category->Questions' results in a cycle. Cycles are not allowed in no-tracking queries. Either use a tracking query or remove the cycle.
Is tracking really required, when handling multiple same-level properties of the Entity?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment