Description
> EF Core will then enable lazy loading for any navigation property that can be overridden--that is, it must be virtual and on a class that can be inherited from.
The above statement from this docu page seems misleading to me: it hints that navigation properties can be virtual or not, and if they're not virtual, they will simply not be lazy-loaded.
Instead it would seem that if lazy loading is enabled EVERY navigation property on EVERY model of such a db context has to be virtual, because else we will see exceptions being thrown on app startup by .migrate()
!
Another: There seem to be some requirements about constructors in models. Queries that used to be working before enabling lazy loading are now throwing because "Can not instatiate proxy of class Blah.Blah Could not find a constructor that would match given arguments."
Because of all of the above it would seem that enabling lazy loading requires some special preparations, far surpassing installing the NuGet package this docu page mentions and adding .UseLazyLoadingProxies()
to startup.cs
.
I can not see these requirements documented here. I'd suggest mentioning them on this page and either documenting them extensively or linking to a separate docu page where they are described.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: bbd36f35-e257-d0ed-8f28-f539ddcb71ec
- Version Independent ID: 093903d5-f7c7-5a78-c0e5-0e2662dcedef
- Content: Loading Related Data - EF Core
- Content Source: entity-framework/core/querying/related-data.md
- Product: entity-framework
- Technology: entity-framework-core
- GitHub Login: @rowanmiller
- Microsoft Alias: divega