When we run our Entity Framework Code First application for the first time, Entity Framework will do the following:
Check the
DbContext
class that is being used.Find the
connectionString
that should be used with this context class.Find the domain entities and extract the schema-related information.
The database will be created.
Data will be inserted into the system.
What will happen if the database already exists? What will happen if the application is run a second time? Should it create the database again or simply use the existing database? These are a few questions that can be answered simply by understanding the database initialization process of Entity Framework.
Once the schema information is extracted, Entity Framework will use database initializers to push the schema information to the database. There are various possible strategies for database initializers, and Entity Framework's default strategy is to create the database if it doesn't exist, and use...