Entity Framework Core Part 4 - Eager vs Lazy Loading
Vložit
- čas přidán 8. 10. 2020
- Are you eager to learn about lazy loading, or lazy when it comes to eager loading? Here we'll compare the option Entity Framework Core has to offer.
Source code available at: github.com/JasperKent/Entity-... - Věda a technologie
Coming up, we've got configuration and migration, but let me know what else you'd like to see on EF Core.
Source code is at github.com/JasperKent/Entity-Framework-Lazy-Loading
Don't miss the next exciting episode. Subscribe at: czcams.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
I just won the day when I discovered your channel ;)
In just 3 or 4 short videos, I've learned more than in some intensive tutorials lasting hours and hours...
Congratulations and thank you so much for sharing your precious knowledge so clearly and straight to the point.
From now on I will be checking out your excellent work regularly, and I will certainly recommend your channel to my colleagues.
Once again I am really grateful for your generous altruism!
Cheers from Portugal.
Thanks for your kind words - and yes, do spread the word!
all your videos are great. Thank you
I have seen several videos on efc made by others but no one has ever talked about these particular issues that are essentials for programmers.
Happy to have discovered you, Thank's a lot!
this is one of the best Ef tutorials i have ever seen thank you sir for you videos
Great video! Just started to play around with EF and I couldn't wrap my head around the concepts of eager and lazy loading. Thanks for such explanation.
I'm new in EF and your videos are huge help for me. Thank you a lot. As quality content as yours should have many more viewers.
Amazing Work. This is one of the well explained content, that digs deep and at the same time keeps it simple.
ty man. I love you and your tutorials . GJ
Amazing thank you! I have a relatively big C# desktop application but coding isn't my day job and I'm currently hitting problems with this. I was using explicit loading and wasn't always ending up with the data loading fully.
I need to refactor and tidy the backend anyway but I'm certain that in my case lazy loading will be the solution. Very clearly explained thank you. Not sure why you have so few subs so far but you have one more now 😊
EDIT: and yes, my data structures are complex enough that using eager loading every time would be *ridiculous*.
Thanks. It takes time to get subscribers, but do spread the word.
Thank you for the great explanation!
I've been having troubles with Lazy loading, seems like I should go with Eager loading instead.
How is that posible that i always get recomended from youtube some random indian guy from which i dont learn anything? This guy is underated genius. Hilarious video please keep it up :) your video actualy teached me a huge amount of useful information per just few minutes. Thank you sir. And please please keep it up. :)
Glad you liked it.
Awesome explanation, solved me a problem. Thank you so much!
Thank you very much for this content. Very helpful.
Great explanation. Very clear.
practical , understandable, comprehensive detailed Thanks Don keep on
Glad you liked it!
It's very useful! Thank you!!!
Amazing video thank you. Keep going :D
Great video! thank you.
Wow thank you so much!
Thanks for interesting video!!! But why do we use SQLite throught whole course, why don't MSSQL or MySQL?
One of the key points of Entity Framework is that it works the same way, regardless of database, as long as the feature in question is supported by the database. SQLite just seems easiest, as it doesn't need any additional installation. But I use MSSQL sometimes.
@@CodingTutorialsAreGo All right! Thanks!
If AutoMapper with ProjectTo() LINQ extension method is used... and if the actual mapping involves getting data from related tables/entities (via ForMember() method, for example)... then how does it mesh with EF loading modes? Which method of loading related data is used by EF under the hood?
Thanks.
I'm afraid I don't know. I've not use AutoMapper that way.
So is there any difference in using a loop and .take to batch out queries to more manageable sizes in core than EF6? Does using async methods change that?
Thanks for the question. I don't know of any differences in that area between EFCore and EF6. However, you're right about async, particularly with the new IAsyncEnumerable in C#8. This video covers it: czcams.com/video/TWBqRA3s--M/video.html. Doesn't use EF, but you can imagine putting whatever you like in the middle of the loop.
@@CodingTutorialsAreGo Seems like a test using something like Brian Chavez 's Bogus to fill up a faux data base and then see how performance works in different scenarios and how to handle it. Maybe that would make a good video on speed? BenchmarkDotNet to test the speed.
What if you have self referencing tables which you cannot know the depth. For example you can have an object inside an object inside an object and so on. If the depth of this is user defined I cannot imagine how this would be achievable with eager loading. Loading an unknown amount of nested objects would be I think way to complicated and has to be done recursively which is also not that performant
Great question. I've hit that problem myself, using the composite pattern. As far as I know, if you're doing eager loading, you have to be explicit about how many levels you go down. Otherwise, it would be possible to accidently pull in vast amounts of data. What I do is use eager loading to a depth that I think is a reasonable guess, and then also have lazy loading (or possibly explicit loading) to catch those rare, extra-deep cases.
@@CodingTutorialsAreGo Ok so you can basically specify the depth for eager loading? Can you do this in EF core?
@@florent9555 Yes, you do something like
context.rootSet
.Include (rs => rs.Children)
.ThenInclude (c => c.Children)
.ThenInclude (cc => cc.Children);
chaining as many 'ThenInclude's as you want.
Hey good video, but can you explain the stuff little slow. We all are new to this.
Ok, no abuse lazy loading is good