EF Code First Migrations: MigrateDatabaseToLatestVersion without NUGET

Viewed 8225

I need help to clarify how EF Code First Migrations works on production machine. I've some entity classes and DbContext-derived class to access entities. Now, I want to perform these several things:

  • when my application starts, it must create database, if database does not exists;
  • then database schema must be adjusted to the model;
  • if database was created just now, I want to create some indexes;
  • also, if database was created just now, it must be seeded by some initial data;
  • all of these things must be performed automatically, without any NUGET commands or external tools.

I've read some articles about migrations, but they're focused mostly on NUGET usage or pure automatic database updates at run-time (via MigrateDatabaseToLatestVersion). I know about DbMigration class, but I can't understand, how to glue together MigrateDatabaseToLatestVersion strategy and DbMigration.

UPDATE.
In fact, I cannot use NUGET in the project and I need possibility to make a migration "by hand".

1 Answers
Related