Saturday 10 February 2018

Database First Approach in MVC.

In this article, We will discuss about How to Create Database First Approach in MVC.

First of all, Create one Sample MVC Application and also Consider One Database and in that Database Create one table.

Goto Visual Studio -> Goto Solution Explorer.

Now, We need to add an "ADO.NET Entity Data Model" and Which can be add in any Folder or you can add under Project also and here, i added under my Models Folder.

Goto Models Folder -> Right Click on it -> Click Add -> Click "New Item" -> Then a new PopUp Will Come and there we need to select "ADO.NET Entity Data Model" and Which is Shown in below figure,


Click Add and a new Popup Will Come Which is Shown in below figure,


Click Next and a new Popup Will Come.

After that, Click New Connection and FillUp all the required Details and Click Ok.

Click "Yes, include the sensitive data in the connection string" and Which is Shown in below figure,


Click Next -> then We need to Choose the Entity Framework Version and Click Next.

In the last, We need to Choose What are the tables,Views and Stored Procedures and Functions need to add and Which is Shown in below figure,


Click Finish.

After that an edmx File added under that Particular Location and also a ConnectionString added under Web.config file, Which is shown in below figure,


By Using the Entities Class now we Can Perform our CRUD to that Particular table.

Note:- This is Just a sample Application and you can change as per your requirement.

0 comments:

Post a Comment