Implement Database First Approach with Entity Framework

In this blog, we going to learn about the database first approach. If we want to perform business operations with the existing database, it's better to go with database first approach to avoid manual creation of the model.

Step 1

Install Entityframework from NuGet (check whether you have installed it or not).


Step 2

Create ADO.NET entity data model



Step 3

Select from EF designer from the database to excute database first approach and in the image given below, you can see other way of the approach. We will see those in an upcoming article.



Step 4

Configure Connection and select respective database 



Step 5

Now, you can see the configured connection string.



Step 6

Select respective tables to map with the application.



Now, you can see the created edmx.


Advantage of Database First
  1. It is very popular if you have the database designed by DBAs, developed separately or if you have an existing database.
  2. EDM wizard creates entities, relationships, and inheritance hierarchies for you. After modification of mapping, you can also generate POCO class entities.
  3. To add the extra features in POCO entities, you must either T4 modify template or use partial classes.
  4. Manual changes to the database are possible because the database defines your domain model. You can always update model from the database.
I hope, this helps.