In database related programming, we can hear about 2 key words "code first - database first" when we start to design backend architecture. So, what is code/database first? Is it important in coding ?
The answer is yes, it helps you easily control model database and manages owner resource better.
Code-first
We will not create the tables under the database first, but rely on the classes/models on C# to create the database. Net supports Entity Framework Core - is an Object/Relational Mapping (O/RM) framework. It is an enhancement to ADO.NET that gives developers an automated mechanism for accessing & storing the data in the database.
The neweset EF core version is 7.0. Find out more in: https://learn.microsoft.com/en-us/ef/core/what-is-new/
In the code-first approach, EF Core API creates the database and tables using migration based on the conventions and configuration provided in your domain classes. It creates the database based on the parameter passed in the base constructor of your context class- using DB context.
Database-first
Otherwise, we already have tables under the database and we just need to create C# classes to map those tables. We also use EF build a data object model and the complete application for you with very little code.
Example:
In short, the code-database first technique in backend system design is extremely necessary for users. You will understand what system architecture you need and what is important in backend design.
Top comments (2)
This is my first blog, if there are any mistakes please comment, I will improve it better.
Wow! it great.