Database initialization strategies
Creating the Database for the first time isn’t the only thing we need to worry about; for example, how can we keep track of the changes that will definitely occur to our Data Model?
In previous versions of EF (up to 6.x), we could choose between one of the Database management patterns (known as Database Initializers or DbInitializers) offered by the Code-First approach, that is, by picking the appropriate Database initialization strategy for our specific needs: CreateDatabaseIfNotExists
, DropCreateDatabaseIfModelChanges
, DropCreateDatabaseAlways
, and MigrateDatabaseToLatestVersion
. Additionally, should we need to address specific requirements, we can also set up our own custom initializer by extending one of the preceding and overriding their core methods.
The major flaw of DbInitializers was them not being immediate and streamlined enough for the average developer. They were viable, yet difficult to handle without an extensive knowledge of the whole Entity...