-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Can't Disable Lazy Loading #15802
Comments
By default EF Core does not load related entities and #4851 has an explanation of why IncludeAll does not exist. |
@MelbourneDeveloper In addition to the comments from @AndrewBoklashko above, it seems like the main thing that isn't clear here is that lazy-loading being turned off doesn't mean that EF will eagerly load everything. It just means don't lazy-load, even if you have entities that would normally lazy-load. |
@ajcvickers this was a misunderstanding on my part. The problem that it is not possible to load all data in one hit still stands though. EF Core at least needs an IncludeAll. |
@MelbourneDeveloper As pointed out above, this issue indicates that we believe |
I think there are legitimate use-cases for IncludeAll and it should be included in the next EF release. As a work-around, I think this implementation for IncludeAll can be used: https://stackoverflow.com/a/64614824/14855926 |
Describe what is not working as expected.
This should turn lazy loading off, but it doesn't:
What makes this problem so much worse is that there seems to be no IncludeAll method in EF core.
Steps to reproduce
Download this sample and run it:
https://www.dropbox.com/s/mimvgvcmibr7em2/EFSQLiteTest.7z?dl=0
Notice that it creates a Person with an Address (BillingAddress).
You can see that Entity is created correctly by opening the SQLite file with SQLite DB Browser. The address is created, and Person has a foreign pointing to the Address record.
When the Person Entity is loaded, the BillingAddress is null. You will see an exception
Lazy loading has not been turned off despite LazyLoadingEnabled being set to false.
The only way to load the BillingAddress property is to explicitly Include it. This means having to explicitly specify that each child property be loaded and that is far too onerous.
Further technical details
EF Core version: Microsoft.EntityFrameworkCore.Sqlite 2.2.4
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: Windows
IDE: Visual Studio 2017 15.9.11
Platform: .NET Core 2.2
The text was updated successfully, but these errors were encountered: