Skip to content
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

UseLazyLoadingProxies enforces every entity to use lazy loading #11907

Closed
bugproof opened this issue May 4, 2018 · 4 comments
Closed

UseLazyLoadingProxies enforces every entity to use lazy loading #11907

bugproof opened this issue May 4, 2018 · 4 comments

Comments

@bugproof
Copy link

bugproof commented May 4, 2018

I'm just testing lazy loading feature in EF Core 2.1

https://docs.microsoft.com/en-us/ef/core/querying/related-data#lazy-loading

It seems like using it enforces marking all navigation properties with virtual. And if I don't do so I get this exception:

UseLazyLoadingProxies requires all entity types to be public, unsealed, have virtual navigation properties, and have a public or protected constructor.

Is this by design? Or is it better if I use "Lazy-loading without proxies" if I want to have some entities loaded differently.

The documentation doesn't mention this:

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

But it seems like all navigation properties must be virtual whether I want to use it or not.

@ralmsdeveloper
Copy link
Contributor

This is by design enforcing all properties to be of the virtual type when LazyLoad is enabled.

@ralmsdeveloper
Copy link
Contributor

ralmsdeveloper commented May 4, 2018

You can suggest something here too: #10787

If you want to have only a few properties loaded you can use the:
https: //docs.microsoft.com/en-US/ef/core/querying/related-data#lazy-loading-without-proxies

@ajcvickers
Copy link
Contributor

Duplicate of #10787

@ajcvickers ajcvickers marked this as a duplicate of #10787 May 4, 2018
@dfcowan
Copy link

dfcowan commented Aug 3, 2021

It would be helpful for the documentation to mention this. As it's written today it implies that only virtual properties will be overridden.

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.

from https://docs.microsoft.com/en-us/ef/core/querying/related-data/lazy

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants