1

I'm using miniprofiler and noticed that immediately after a rebuild it's giving me a crazy number of sql calls (485).

enter image description here

But the next time I call the page it seems to be caching / re-reading the result, because the call times are minimal. However the sql calls have reduced to a reasonable number (3). Also this seems to be a new occurance but I can't pinpoint when it started exactly.

Therefore I'm confused as to whether or not I have a problem. Does anybody know if this pertains to the rebuild and can I safely ignore it?

Or is it something I should investigate further?

enter image description here

Martin Hansen Lennox
  • 2,837
  • 2
  • 23
  • 64
  • What is "a crazy number"? I think this is just EF checking the database structure against the model hash it has stored in the migration table (maybe 10-15 queries). This only happens when an application is started and a context is used for the first time. – Gert Arnold Mar 11 '14 at 11:15
  • Thanks Gert. 485 is the crazy number. There's about 20 tables, one of which stores 10 or so derived classes (table per hierarchy). – Martin Hansen Lennox Mar 11 '14 at 14:59

1 Answers1

0

Looks like MiniProfiler is recording all of the db calls made when you are attempting to drop and recreate the database.

If you don't want to record these and still want to profile that request, then try using the Ignore command in MiniProfiler.

using (MiniProfiler.Current.Ignore()) 
{
  DbDatabase.SetInitializer<MyDBContext>(
                            new DropCreateDatabaseIfModelChanges<MyDBContext>());
  DbDatabase.Initialize(false);
}

Include the Initialize function call within the Ignore block in order to make sure that initialization happens when you want it to happen.

Yaakov Ellis
  • 40,752
  • 27
  • 129
  • 174