In the previous article, we learned about the code-first approach of the Entity Framework.
A Simple Step to Entity Framework: Code First Approach.
Now we are discussing the database first approach.
This approach uses the development scenario of our database is already developed and we have an existing database and we need to go directly to the coding part. So we can directly create the EDMX for the existing database and we have the option to update the data model when the database schema is changed.
A quick start
Create an application.
Add a new item to the project.
Add an ADO.NET Entity Data Model.
Select the option Generate from Database and click on the Next button.
Click on the New Connection button.
Enter the credentials of the database server and select the database name in this wizard.
Our connection details will show in the next wizard. Click on the Next button.
In this wizard, we have the option to select the tables, views, Stored Procedures, and functions. Click on the Finish button.
Now our EDMX s created.
Right-click on the diagram; we can see many options for managing the EDMX.
Here one of the options is Update Model from Database, it is for updating the model when we have changed in the database schema.
In this article, we learned the basic details of the Database First Approach of the Entity Framework.