-
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
Query exception after upgrading from 6.0.1 to 6.0.2 #27600
Comments
@MariovanZeist In order to fix the problem add ToList to the collection inside the projection: var roles = await ctx.Users.Where(u => u.Id == Guid.NewGuid()).Select(u => u.Roles.Select(r => r.Name).ToList()).FirstOrDefaultAsync(); |
Thanks @maumar var roles = await ctx.Users.Where(u => u.Id == userId).SelectMany(u => u.Roles.Select(r => r.Name)).ToListAsync(); But I have several more queries that fail after the upgrade so I was forced to revert back to 6.0.1. |
I can circumvent the problem by adding AppContext.SetSwitch("Microsoft.EntityFrameworkCore.Issue27105", true); To my startup code I believe the problem has been introduced here: #27134 So I will test to see if this alleviates my problems, so I can upgrade to 6.0.3. |
This improves the fix made in #27134 In earlier PR we converted `IQueryable<T>` to `IEnumerable<T>` becaused we converted enumerable to queryable during preprocessing phase and types aligned in later phase since we create a list (which does implement `IEnumerable<T>`). Though this implementing behavior doesn't work when returning a single result of enumerable during async which wraps collection type inside Task. The better fix is to assign `List<T>` as type since we are eventually creating a list. In case of single result, the single result operator has generic type which will introduce convert node into it automatically which will match types for async tasks. Resolves #27600
This improves the fix made in #27134 In earlier PR we converted `IQueryable<T>` to `IEnumerable<T>` becaused we converted enumerable to queryable during preprocessing phase and types aligned in later phase since we create a list (which does implement `IEnumerable<T>`). Though this implementing behavior doesn't work when returning a single result of enumerable during async which wraps collection type inside Task. The better fix is to assign `List<T>` as type since we are eventually creating a list. In case of single result, the single result operator has generic type which will introduce convert node into it automatically which will match types for async tasks. Resolves #27600
Just chiming in to say that I also had this issue, and confirming that it is now fixed in the 6.0.5 release.
I didn't find this issue sooner because it doesn't mention |
After upgrading all packages to 6.03 I have a query that fails.
(Problem also occurs when upgrading from 6.0.1 to 6.0.2)
I have the following query (The DbContext is the default IdentityDbContext)
(The query gets the user roles from the user)
in 6.0.1 it returns an
IEnumerable<string>
containing the rolesin 6.0.3 (and 6.0.2) it generates an exception:
with the following stacktrace:
To reproduce:
https://github.com/MariovanZeist/EFCoreTest
and follow the
readme
I am (trying) to use EF Core 6.03
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 6.0)
Operating system: Windows VS 2022 (17.1)
The text was updated successfully, but these errors were encountered: