Difference between Configuration.cs vs Database Initializer in Entity Framework
Configuration.cs file located inside Migrations folder, which will be created when we execute the command “Enable-Migrations” in Package Manager Console. We can make use of this class for seeding the datas into database.
This class will seed the database whenever we execute the Update-Database command in Package Manager Console. To avoid duplicate seeding we can make use of Any method of context dbSet or the extension method AddOrUpdate of dbSet.
But what if a scenario we want our database to be populated with datas in it when it was created initially, instead of verifying the data exists with Any or AddOrUpdate method to avoid duplicate. For that case we use DBInitializer which comes with three ways, like 1. Drop and Create database always, 2. DropAndCreateDatabase if model changes, 3. CreateDatabaseIfNotExists