5 - Lazy Loading in Entity Framework
Vložit
- čas přidán 7. 04. 2019
- Lazy loading means delaying the loading of related data, until you specifically request for it.
For lazy loading Navigation property should be defined as public and virtual. Context class will not do lazy loading if property is not defined as virtual.
Lazy loading is default phenomenon.
When using POCO entity types, lazy loading is achieved by creating instance of derived proxy types and then overriding virtual properties.
U are life saver. love from Pak
Superb tutorial
Good explanation ☺️.. simple and clear
Simple and Good explanation
Thank you! It's nice to have a female professor, I have't had that in my four years of uni!
A tip: you can watch series at KaldroStream. Me and my gf have been using it for watching all kinds of movies lately.
@Damian Clyde Yea, I've been using flixzone} for years myself :)
@Damian Clyde Yup, been watching on Flixzone} for since november myself :)
The common property in our case 'CityId' needs to be same ? I mean if I have 'Id' in city class and 'CityId' in Area class ? Will it work ? Trying this it's not working at my side.
Did you configure the FK(Foreign Key) properly in database and then generated Entity framework classes?
Let me know this, then only I can answer you question.
what is POCO entity ?
Hi!
Personally I don't like the idea of code first migration so I manualy created a script to create the database scheme and then I runned >>
scaffold-dbcontext -provider Microsoft.EntityFrameworkCore.SqlServer -connection "My_connection"
That created the classes I need to interact with database. Is that a good thing to do or we should use the CodeFirst way? please help
U should use code first to have the full control on Db otherwise It's a bit difficult to manage everything. For professional project i recommend code first as i had a bad experience with db first. For example a varchar(25) column u created in your table and if u generate entity from your db the column length won’t be written in entity class and if u manually define max length data annotation in entity class Field then every time u regenerate your entity class from db in case of any updates in db to affect entity class, the total entity class will be regenerated as a result any previous annotation in class will be replaced even though u can preserve the annotation only by creating additional partial class then configure class which is not hassle free. So think for your best approach.
@@morsheddld Thanks Morshedul for the answer. I think the database model should not frequently changed. I used both approaches I found dB-first more cleaner approach for my side, I’ll think about your advice, thanks again.
Cuckoo sound is nice from 11:37...