I have tried to profile my wpf application concentrating on non-visual parts that do some calculations and evaluations, I have used Visual Studio 2012 bulit in profiler.
There is quite a lot of code (tens of thousands of lines) in that application, so I was surprised that it showed 46.3% time spent on a single line:
db.Entry(qzv.ZkouskaVzorku).Collection(p => p.VyhodnoceniZkouskies).Load();
This line should just explicitly load related entities as specified here.
I have checked this line using SQL Express profiler and it showed only this SQL command:
exec sp_executesql N'SELECT
[Extent1].[VyhodnoceniZkouskyID] AS [VyhodnoceniZkouskyID],
[Extent1].[Kontext] AS [Kontext],
[Extent1].[NormaVlastnostiID] AS [NormaVlastnostiID],
[Extent1].[ZkouskaVzorkuID] AS [ZkouskaVzorkuID],
[Extent1].[ZkouskaTypuID] AS [ZkouskaTypuID],
[Extent1].[JeShodaITT] AS [JeShodaITT],
[Extent1].[JeITT] AS [JeITT],
[Extent1].[JeStorno] AS [JeStorno]
FROM [dbo].[VyhodnoceniZkousky] AS [Extent1]
WHERE [Extent1].[ZkouskaVzorkuID] = @EntityKeyValue1',N'@EntityKeyValue1 int',@EntityKeyValue1=1816601
go
And this command executes very quickly in 0 ms as it is just selecting several rows using primary clustered index.
Using Entity framework 6.1.0 with SQL Server LocalDB 2014. I have commented this line as it is important only for ViewModels and the calculations really work cca 2x faster.
What could be the issue and is there any workaround to fix it?