Diagnostics analyzer for unnecessary Include
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
Good morning,
after upgrading Entity Framework Core to .NET 6 I faced a breaking change on my production API that was not listed on [these docs](https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/breaking-changes).
It is related to `Microsoft.EntityFrameworkCore.Query.NavigationBaseIncludeIgnored` that change the EF Core behaviour when using [multiple level properties](https://docs.microsoft.com/en-us/ef/core/querying/related-data/eager#including-multiple-levels).
The solution is explained on this question on [Stack Overflow](https://stackoverflow.com/questions/70555317/multiple-level-properties-with-ef-core-6).
**Old working code:**
```c#
Tour tour = await _context.Tours.Include(mpt => mpt.MarkersPerTours)
.ThenInclude(mrk => mrk.Marker)
.ThenInclude(mrkProp => mrkProp.MarkersTranslations)
.ThenInclude(mrk => mrk.Marker)
.ThenInclude(mrkTp => mrkTp.Type)
.FirstOrDefaultAsync(t => t.Id == tourId);
```
**New working code:**
```c#
Tour tour = await _context.Tours.Include(t => t.MarkersPerTours)
.ThenInclude(mpt => mpt.Marker)
.ThenInclude(mrk => mrk.MarkersTranslations)
.Include(tour => tour.MarkersPerTours)
.ThenInclude(mpt => mpt.Marker)
.ThenInclude(mrk => mrk.Type)
.FirstOrDefaultAsync(t => t.Id == tourId);
```
Can it be a good idea to include it in the docs?
Thank you
Contributor guide
Assessment
This issue has not been assessed yet.