-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Including reference navigation and projecting collection navigation throws #18090
Comments
I get same error in ubuntu18 and EFCore 3.0.0 var invoices = context.Invoice
.Include(i => i.CustomerFkNavigation)
.ThenInclude(c => c.SomeCustomerDataFkNavigation)
.ToList()
.Select(i => new Invoice()
{
Id = i.Id,
CustomerFkNavigation = i.CustomerFkNavigation,
InvoiceLine = i.InvoiceLine
}); |
@guftall This only works for small datasets as all you're doing is storing the entire table in memory, which would result in very poor performance with a lot of data. |
Issue: Earlier we expanded navigation in selector and include in separate phase. This causes issue because if the latter visitor expands a reference navigation then former visitor's collection expansions have incorrect references. Fix: Fix is to make include expansion part of selector expansion as next phase. So by the time we apply include, the correlation predicate in collection hasn't been converted to actual reference. So when it gets converted, it takes correct reference. Also apply pending selector inside lambda expression since it is a subquery. This caused issue when subquery has a projection which has navigation to expand, which we never visited. Resolves #18127 Resolves #18090 Resolves #17852 Resolves #17756
Issue: Earlier we expanded navigation in selector and include in separate phase. This causes issue because if the latter visitor expands a reference navigation then former visitor's collection expansions have incorrect references. Fix: Fix is to make include expansion part of selector expansion as next phase. So by the time we apply include, the correlation predicate in collection hasn't been converted to actual reference. So when it gets converted, it takes correct reference. Also apply pending selector inside lambda expression since it is a subquery. This caused issue when subquery has a projection which has navigation to expand, which we never visited. Resolves #18127 Resolves #18090 Resolves #17852 Resolves #17756
Issue: Earlier we expanded navigation in selector and include in separate phase. This causes issue because if the latter visitor expands a reference navigation then former visitor's collection expansions have incorrect references. Fix: Fix is to make include expansion part of selector expansion as next phase. So by the time we apply include, the correlation predicate in collection hasn't been converted to actual reference. So when it gets converted, it takes correct reference. Also apply pending selector inside lambda expression since it is a subquery. This caused issue when subquery has a projection which has navigation to expand, which we never visited. Resolves #18127 Resolves #18090 Resolves #17852 Resolves #17756
Issue: Earlier we expanded navigation in selector and include in separate phase. This causes issue because if the latter visitor expands a reference navigation then former visitor's collection expansions have incorrect references. Fix: Fix is to make include expansion part of selector expansion as next phase. So by the time we apply include, the correlation predicate in collection hasn't been converted to actual reference. So when it gets converted, it takes correct reference. Also apply pending selector inside lambda expression since it is a subquery. This caused issue when subquery has a projection which has navigation to expand, which we never visited. Resolves #18127 Resolves #18090 Resolves #17852 Resolves #17756
Issue: Earlier we expanded navigation in selector and include in separate phase. This causes issue because if the latter visitor expands a reference navigation then former visitor's collection expansions have incorrect references. Fix: Fix is to make include expansion part of selector expansion as next phase. So by the time we apply include, the correlation predicate in collection hasn't been converted to actual reference. So when it gets converted, it takes correct reference. Also apply pending selector inside lambda expression since it is a subquery. This caused issue when subquery has a projection which has navigation to expand, which we never visited. Resolves #18127 Resolves #18090 Resolves #17852 Resolves #17756
Issue: Earlier we expanded navigation in selector and include in separate phase. This causes issue because if the latter visitor expands a reference navigation then former visitor's collection expansions have incorrect references. Fix: Fix is to make include expansion part of selector expansion as next phase. So by the time we apply include, the correlation predicate in collection hasn't been converted to actual reference. So when it gets converted, it takes correct reference. Also apply pending selector inside lambda expression since it is a subquery. This caused issue when subquery has a projection which has navigation to expand, which we never visited. Resolves #18127 Resolves #18090 Resolves #17852 Resolves #17756
@smitpatel confirmed fixed as of |
How can such obvious bugs make it to RTM? |
Or can we use this preview package? I don't see it published on nuget. Is there another way of getting it? |
@clement911 on nuget there are only preview releases, this is fixed for preview 3 but that's not out yet. It is available in daily builds for which you can find instructions here https://github.com/aspnet/AspNetCore/blob/master/docs/DailyBuilds.md |
Got it thank you. Seems a bit risky for production so I guess I'll have to wait. |
I'm facing to the same problem. If it's included in 3.1, do you have any idea of the release date ? |
@heyligengregory 3.1 will come start of December 2019 |
Can you please include basic regression queries in the test suite? It's not like it's a super complicated query and it throws a runtime error. |
@clement911 No offense but did you read the issue ? It clearly says that this issue is in the preview3 milestone, that it is closed as fixed (I even confirmed it in a message with the version detail), and if you look at the last commit (47f6cef) you will find tests called This answers all your questions, and all the information was already there. |
No offence taken. I'm a user of EF core and not a contributor. I'm not familiar with the inner workings of EF core or its testing code base (I wish I had time to). I come from a user perspective and I just wanted to point out that it seems like such a severe regression on such a simple query should have been caught before EF Core 3.0 was released. |
@clement911 Yes, that's fair. That's why we run more than 50,000 tests on every build. However, the problem space for different queries is huge. Combine this with different models and model configurations and it gets even bigger. So sometimes things get missed. We do our best and continually strive to do better, but we make mistakes. |
Fair enough. Apologies if I came out too strong but it was quite frustrating to have to abort our 3.0 migration after battling through all of the asp.net core migration issues because of this issue. |
@clement911 with dotnet/announcements#139 or https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/3.1.0-preview3.19554.8 it should be fixed now |
Sweet thank you @Suchiman |
When using
.Include().ThenInclude()
and selecting a collection, EF throws anInvalidOperationException
with errorEF.Property called with wrong property name.
Note that also using
.Include()
on the selected collection still throws.The only "workaround" is to avoid
.ThenInclude()
which is not a solution for me (I needSomeCustomerDataFkNavigation
)Steps to reproduce
Further technical details
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0
Operating system: Windows 10 x64
IDE: Visual Studio 2019 16.3.1
The text was updated successfully, but these errors were encountered: