0

I made a new asp.net mvc4 app and then installed miniprofiler.

then i just enabled-migration and after adding migration i updated my database.

using miniprofiler i found out there are 3 sql queries that i don't know about them.

i don't know where this initialization take place

 InitializeDatabase <PerformDatabaseInitialization>b__6 PerformInitializationAction PerformDatabaseInitialization

here is a picture of the miniprofiler miniprofiler

what are these 3 sql queries? where they come from?

Amir Jalali
  • 3,132
  • 4
  • 33
  • 46

1 Answers1

0

This is EF Migrations checking if the database is the same as the EF model. Whenever you run a migration EF stores details of the migration in the [__MigrationHistory] table so it knows if the migrations need to be run.

  • I'm not too sure about first query but I think it's checking if any tables in the db were generated using EF (This is a guess from looking at the stack trace).

  • The second query just returns the number of migrations.

  • The final query gets the latest migration which will then be compared to the EF model. If the model is different to the database an exception will throw saying the database is out of date.

You don't need to worry about these as the migration check is only run once per application startup.

If you want more info on db initialisers take a look at this.

Adam Flanagan
  • 3,052
  • 23
  • 31