Answer the question
In order to leave comments, you need to log in
Do I need to use lazy loading in entity framework?
The essence of the question is whether it is good practice to use lazy or not. The question actually appeared for the reason that while working on the project, the generation of models from the database was used, which does not allow to disable the option to pick up keys from the database. As a result, we got models with a bunch of lazy fields. A couple of times I found that a colleague does not understand how it works. For example, we had 2 tables, 1 has a key to the other 1 to many. He made a selection on 1 table. I passed it to the view and there in the collection loop I used the lazy property to get the property from the 2nd table. As a result, a query is sent to the database for each element 1 of the table. Which is clearly not very good. Again, if you use a lazy field in building a request, then a terrible request is generated.
Answer the question
In order to leave comments, you need to log in
The practice of not dragging data if it is not needed is a good one. The practice of dragging data for each row is bad. You should just explain how lazy works to a colleague.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question