Code First Flashcards

1
Q

What is the Code-First approach?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the Code-First also require?

A

A context class which should be
derived from DbContext class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the four different database initialization strategies?

A
  1. CreateDatabaseIfNotExists
  2. DropCreateDatabaseIfModelChanges
  3. DropCreateDatabaseAlways
  4. Custom DB Initializer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is CreateDatabaseIfNotExists?

A

This is the default initializer, it will create the database if none exists as per the configuration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is DropCreateDatabaseIfModelChanges?

A

This initializer drops an existing database and creates a new database, if your model classes (entity classes) have been changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is DropCreateDatabaseAlways?

A

This initializer drops an existing database every time you run the application, irrespective of whether your model classes have changed or not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Custom DB Initializer?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly