1

I am using Singleton pattern for my application, I have used ADO.NET Entity framework as my Data Access Layer, after login to my application, it's taking 3 to 5 minutes to load the dashboard.

Is there a way to reduce the time? Or I have to look for some other methods instead of Entity framework?

gnat
  • 21,442
  • 29
  • 112
  • 288
  • 3-5 minutes is really long time. You should try using something like EFProf to check if there is something wrong. – Euphoric Dec 19 '13 at 10:21

2 Answers2

3

Entity Framework does have a warm up time but it's a couple of seconds. 3-5 minutes suggests something seriously wrong with your queries.

You should use something like Linqpad to see what SQL your LINQ to Entities is generating and work at optimizing it. Assuming of course you have done some troubleshooting and worked out that the DAL is your problem area.

If you are happy with the queries another area to look at if the data changes a lot is your indexes. Check your SQL Statistics are up to date and the fields being used for filtering are indexed.

Lotok
  • 1,759
  • 2
  • 17
  • 27
  • I emphasise the comment about checking your indices. The last time I had an issue like the one you describe, a single foreign key had not been declared. EF does not take that long to initialise. – Mr Cochese Dec 19 '13 at 11:50
2

Feel free to downvote since ORMs seem popular these days, but...

WHY are you using Entity Framework? Is there a possibility that the backend database might change? Are you nervous about writing SQL stored procedures to deliver your data?

Or possibly does it seem that writing a lot of transforms from DbDataReader rows to your objects might be a lot of work?

I'm asking because I've had the misfortune to work on a couple of projects where the developer went for Entity Framework and specifically, was ordered by management to rip it out and go to decent SQL Stored Procs (which can be optimized and have an execution plan) and datareaders PURELY because of the godawful performance you have also experienced.

Where a dashboard requires (according to SQL Profiler) in excess of 48,500 database calls to return before it ever loads, there is an issue. I never see this addressed, so I'm hoping some kind soul will enlighten me.

Rich Bryant
  • 165
  • 4
  • 4
    Just want to point out that if a developer writes EF code that makes 48,500 database calls to load a page, the fault is with the developer, not EF. – Eric King Dec 27 '13 at 20:12
  • Is it? When the domain model is a huge tangle and EF is Lazy Loading navigation properties everywhere via single roundtips to the database? – Rich Bryant Dec 27 '13 at 20:16
  • 1
    Yeah, I feel pretty safe to say, yes, it's the developer's fault. I can think of no reason, regardless of the domain model, for that many db calls. Somebody doesn't know how to use their tools. – Eric King Dec 27 '13 at 20:23
  • In this case, I accept that the developer was probably responsible. But he used EF to deal with a recursive data structure so... inevitable. I used ADO.NET and SQL2012's Hierarchy data type. – Rich Bryant Dec 27 '13 at 21:43