Code First Flashcards
What is the Code-First approach?
The focus on the domain of your application and start creating classes for your domain entity rather than design your database first and then create the classes which match your database design.
What does the Code-First also require?
A context class which should be
derived from DbContext class.
What are the four different database initialization strategies?
- CreateDatabaseIfNotExists
- DropCreateDatabaseIfModelChanges
- DropCreateDatabaseAlways
- Custom DB Initializer
What is CreateDatabaseIfNotExists?
This is the default initializer, it will create the database if none exists as per the configuration.
What is DropCreateDatabaseIfModelChanges?
This initializer drops an existing database and creates a new database, if your model classes (entity classes) have been changed.
What is DropCreateDatabaseAlways?
This initializer drops an existing database every time you run the application, irrespective of whether your model classes have changed or not.
What is Custom DB Initializer?
You can also create your own custom initializer, if the others do not satisfy your requirements or you want to do some other process that initializes the database using the above initializer.