-
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
LazyLoad no Virtual #11865
Comments
@ralmsdeveloper the requirement that all navigation properties are virtual if you enable lazy loading proxies is by design in EF Core 2.1. Our experience with the same feature in EF6 has made prefer a stricter approach: Unintentionally forgetting to make your navigation properties virtual and not realizing that lazy loading wasn't going to kick in until much later seemed to be much more common than wanting to do lazy loading only on some entities. We are open to provide more granular control in the future, but we would like to get more customer feedback before we decide in what direction we move. E.g.:
It would be useful if you could explain what option would work best for you and why. In the meanwhile, you are free to use a modified version of our proxy logic, or to use the lower level building blocks (e.g. ILazyLoader or delegate injection) in your application. |
@divega Thank you so much! You believe there might be the possibility of implementing something like: builder.Property(p => p.Navegator).NoLazyLoad() So it would be more flexible, the user would have the possibility to configure which properties would have LazyLoad. I know and I think all your efforts are very important, I realize that the team has given the best. |
I know that we currently have the possibility of: ILazyLoader or delegate injection |
@ralmsdeveloper sure we could provide granular control at the navigation property level, assuming that is what you meant. No offense taken 😄 Service and delegate injection give you complete control at the cost of more complexity in your entity types. |
Yes, you're right. |
Cover by #10787? |
All right then, I'll follow up on this issue #10787 |
@ajcvickers would like to know what impact this would cause.
I've been working on something where not necessarily I would have "Virtual" type navigators, where today we are forced to declare everything as "Virtual" by activating LazyLoad.
I made a little adjustment where everything works perfectly for me.
Here is an example:
I added just this:
entityType.GetNavigations().Any(p => p.PropertyInfo.GetMethod.IsVirtual))
And:
I believe that with this it would not be necessary to force the user to define a virtual type navigation property.
Thank you in advance.
The text was updated successfully, but these errors were encountered: