Code-First approach allows you to define model classes as per the Domain requirements. Hence, you have complete control over the classes being written or implemented.
In code-first approach the user who is working will only concentrating on creating classes, models and writing code, rest of work like creating database, creating tables, assigning keys, etc, will be look over by the Entity framework.
Thus here the developer will not get the overload of backend works.
The Code-First approach has there own principle or strategy. These strategies are the main backbone of code-first approach. These strategies are also called as database Initializers.
Before going deep into the code, firstly, I would like to give a brief introduction about what these approaches are.
Here, I have explained the Database initializers and how they work in creating and updating records in model.
To add initializers to our dbcontext we need the following things in dbcontext class.
For using all these we need a namespace that is
using System.Data.Entity;
So here I am explaining each and every database initializer and how we can use them in our project.