Skip to content

Can't Disable Lazy Loading #15802

@MelbourneDeveloper

Description

@MelbourneDeveloper

Describe what is not working as expected.

This should turn lazy loading off, but it doesn't:

this.ChangeTracker.LazyLoadingEnabled = false;

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions