-
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
Why entity framework core rc2 lambda expressions select query load all properties that not exists in select #5815
Comments
Related to #4588 |
this issue is tracked here: #6647 |
The Issue still exist in 1.1.0 preview 1 version. inheriting from IdentityDbContext< ApplicationUser > causes to project all properties of an entity. it doesn't happen when entities are not inhering from IdentityDbContext< ApplicationUser > instead of selecting only name and username in the following query all properties are projected.
|
@MohammadAkbari - It happens only in the case, when FK property is nullable (in this case, ApplicationUser.Id is string type which is nullable). Regardless of what property you project out, due to group join, we need to fetch whole related entity. Improvements are tracked at #6647 which is not resolved yet. |
Entity framework core rc2 generates bad sql query in sql profiler, Models and DbContext are given below, The reason for this issue is ApplicationUser inherits from IdentityUser, And this issue also true for other case that use inheritance.
When use query like this:
Generated sql select all prpoerties of User entity, while only need UserName property from user in result as below:
By Join query result is as I expect, query is like this:
But I prefer use first query due to greater readability.
This problem has also been raised in http://stackoverflow.com/questions/37920608/why-entity-framework-core-rc2-lambda-expressions-select-query-load-all-propertie
The text was updated successfully, but these errors were encountered: