Entity-framework code is slow when using Include() many times

前端 未结 3 1841
孤城傲影
孤城傲影 2020-11-29 01:59

I have been debugging some slow code and it seems that the culprit is the EF code posted below. It takes 4-5 seconds when the query is evaluated at a later stage. I\'m tryin

3条回答
  •  没有蜡笔的小新
    2020-11-29 02:31

    Do you have correctly configured relationships between all the entities that you try to 'include'? If at least one entity does not have a relationship to some of other entities, then EF will not able to construct one complex query using SQL join syntax - instead it will execute as many queries as many 'includes' you have. And of course, that will lead to performance issues. Could you please post the exact query(-es) that EF generates in order to get the data?

提交回复
热议问题