question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion on lazy-loading of navigation properties

See original GitHub issue

Note:

  • Issue #10509 has been created to track actual work on lazy-loading. The new issue is locked so that it can be subscribed to for updates on the implementation without noise.
  • This issue has been re-purposed to be discussion about lazy-loading in EF Core. It will not (for the time being) be locked because it is important to us that we don’t shut down channels of communication with the community.

With regard to feedback, I think it is worth reiterating some comments made a few months ago. We read and consider all feedback (and try to make the right choices based on it) no matter how it is delivered; that is, whether it is provided politely and with respect or not. Yelling at us or others with different opinions at best makes you feel good and us/them feel bad. It doesn’t achieve anything concrete. We are doing our best to prioritize features and implement them in the best way we can. We really appreciate your feedback and it makes a big difference on shaping the product. We personally appreciate it more when feedback is delivered in a respectful way, but please don’t stop providing constructive feedback.


Original issue:

Hi,

i was wondering if I am the only one that thinks EF Core is useless without Lazy Loading? Or do I do something wrong? Lets just consider a simple scenario when a course provider cancels a course on a course booking plattform written in MVC.

The user calls courses/cancel/1. The action would get the course and call cancel method like here

Course course = context.Courses.SingleOrDefault(c => c.Id = 1);
course.Cancel();

The cancel method then needs to cancel each booking on the course so it would do something like this

foreach(Booking booking in this.Bookings)
{
    booking.Cancel();
}

The booking in turn would refund the transaction

foreach(Transaction transaction in this.Transactions)
{
    transaction.Refund();
}

So for this to work, lazy loading is needed?! (The solution would be to eager load all the data on the controllers action method. But I do not know what will be needed from the controller?)

I’d appreciate any information on that.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:149
  • Comments:231 (48 by maintainers)

github_iconTop GitHub Comments

91reactions
yukozhcommented, Nov 22, 2015

+1 for lazy load

65reactions
ilmaxcommented, Feb 26, 2018

I would downvote this if possible, lazy loading is a source of problem, and hides some db work. Explicit is better than implicit IMHO! I prefer EF Core never implement this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

the logic of lazy loading with navigation properties in entity ...
1 Answer. In order for lazy loading to work, two things have to happen: Lazy Loading must be enabled on the context. The...
Read more >
Entity Framework performance improvement: [Section 1]
In EF Core, lazy loading is achieved through the use of proxy objects. When an entity is loaded from the database, a proxy...
Read more >
How do you manage non-loaded navigation properties in ...
1. Do nothing. · 2. Make navigation properties nullable. · 3. Create a different DTO for each variant. · 4. Use LazyLoading. ·...
Read more >
Loading Related Data - EF Core
Lazy loading means that the related data is transparently loaded from the database when the navigation property is accessed.
Read more >
How to eager load "Include" navigation properties to avoid ...
I'd like to ".Include" my navigation properties to eagerly load the data, but I haven't a clue where or how to do so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found