Skip to content

Code First with multiple initializers strategies

Notifications You must be signed in to change notification settings

aimenux/EF6Demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EF6Demo

Code First with multiple initializers strategies :

  • Nothing
  • DropCreateAlways
  • CreateIfNotExists
  • NoPendingMigrations
  • MigrateDatabaseToLatestVersion
  • DropCreateDatabaseIfModelChanges

Questions & Answers

Question: What is the difference between Migrations Seed and Initializers Seed ?

Answer:

  • Migration Seed method is for seeding data right after database migration.
  • Initializer Seed method is for seeding data right after database initialization.
  • You can use Initializer Seed method to add initial data to DB right after initialization.
  • You can use Migration Seed method to check and/or add new data or do special things right after migration.

You may apply automatic migration by either using code or using cli/ps commands.

  • Using code, you need to set DatabaseInitializerType to MigrateDatabaseToLatestVersion in program.cs
  • Using cli command (Update-Database), you need to specify an automatic migration configuration type :
    • InsuranceEnableMigrationsV1
    • InsuranceEnableMigrationsV2

Update-Database Examples

Update-Database -Verbose -StartupProjectName App -ProjectName DataAccess -ConfigurationTypeName InsuranceEnableMigrationsV1

Update-Database -Verbose -StartupProjectName App -ProjectName DataAccess -ConfigurationTypeName InsuranceEnableMigrationsV2

Tools : vs19, net framework 4.7.2, entity framework 6.4

About

Code First with multiple initializers strategies

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages