You should use db 'initializer' for whatever you want - and / ore 'Seed' sortings (as for where to enter the EF stream).
You can watch this post with the configured < initializer - , which runs both Db Create ... and Migrate . It doesn’t cut and paste the solution, but it basically works (it was just a quick fix to the problem, you need to correct it a bit, it has a couple of corrections below).
MigrateDatabaseToLatestVersion only part of the migration — and you need seed detection — either manually wrap this part (the main thing is in the “checks” performed for different situations, that is, when you “participate” in the migration — or sowing).
Migration should go first , and the db type 'creation' does not make much sense except sowing.
You redefine seed (you created) to put any db processing in there - you have a DbContext , and you can also call SqlQuery if necessary.
How to create an initializer to create and migrate a mysql database?
source share