Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understanding The navigation '...' was ignored from 'Include' in the query since the fix-up will automatically populate it... and dealing with it #24924

Closed
NatanBagrov opened this issue May 18, 2021 · 4 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@NatanBagrov
Copy link

NatanBagrov commented May 18, 2021

Ask a question

Edit:
related info -
#24225
#23674

Hello,
I'm receiving this warning since updating to 5.0.6 (think it was from 5.0.2):

The navigation 'PurchasingRecordLine.ContainingRecord' was ignored from 'Include' in the query since the fix-up will automatically populate it. If any further navigations are specified in 'Include' afterwards then they will be ignored. Walking back include tree is not allowed.

I'm not sure I understand it.

My models are PurchasingRecord which has many PurchasingRecordLines which have many PurchasingRecordLineActions. Every entity has also a navigation to the parent.

class PurchasingRecord {
    ...
    List<PurchasingRecordLine> Lines { get; set; }
    ...
}

class PurchasingRecordLine {
    ...
    List<PurchasingRecordLineAction> Actions { get; set; }
    PurchasingRecord ContainingRecord { get; set; }
    Guid ContainingRecordId { get; set; }
    ...
}

class PurchasingRecordLineAction{
    ...
    PurchasingRecordLine ContainingRecordLine { get; set; }
    Guid ContainingRecordLineId { get; set; }
    ...
}

When querying - it looks like this:

    Context.Set<TDepartmentRecord>()
    .Include(r => r.AssociatedUser)
    .Include(r => r.Lines)
        .ThenInclude(l => l.Actions)
        .ThenInclude(rs => rs.NextActions)
    .Include(r => r.Lines)
        .ThenInclude(l => l.ContainingRecord)
    ...

Questions and concerns:

  1. What I understand from the warning is: .Include(r => r.Lines).ThenInclude(l => l.ContainingRecord) is redundant since l.ContainingRecord is to be populated anyway. Is that correct?
  2. If this property (l.ContainingRecord) is not being included - what should I do to include it?
  3. If I understood correctly, in order to get rid of these warnings - Should I just omit this inclusion?
  4. Is there any configuration to provide more info about the location of the warning, because I have plenty of queries...

Thanks!

EF Core version: 5.0.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0.6
Operating system: W10 x64
IDE: Rider 2021.1

@NatanBagrov NatanBagrov changed the title Understanding The navigation '...' was ignored from 'Include' in the query since the fix-up will automatically populate it... and dealing with it Understanding The navigation '...' was ignored from 'Include' in the query since the fix-up will automatically populate it... and dealing with it May 18, 2021
@smitpatel
Copy link
Member

  1. Yes
  2. It is being included due to fix-up no matter Include is written or not.
  3. To avoid warnings you can remove the Include which is populating navigation back to parent which will be shown in the warning.
  4. No easy way for us to provide location. We will discuss in team meeting.

@AndriySvyryd
Copy link
Member

AndriySvyryd commented May 18, 2021

#15127 would help identifying the query

You can also enable logging and the Debug level to see query compilation messages.

@AndriySvyryd AndriySvyryd added the closed-no-further-action The issue is closed and no further action is planned. label May 18, 2021
@NatanBagrov
Copy link
Author

NatanBagrov commented May 19, 2021

  1. Yes
  2. It is being included due to fix-up no matter Include is written or not.
  3. To avoid warnings you can remove the Include which is populating navigation back to parent which will be shown in the warning.
  4. No easy way for us to provide location. We will discuss in team meeting.

Thank you for the explanation, @smitpatel !
Can you please elaborate on this "fix-up"? it sound vague.
I guess it "connects" the relevant entities...

@smitpatel
Copy link
Member

https://docs.microsoft.com/en-us/ef/core/change-tracking/relationship-changes#relationship-fixup

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

4 participants