CRUD Operation Using Scaffolded Item in MVC 5 on Model First Approach

It is very simple to do CRUD operations in MVC using Scaffolded items.

Let's begin,
 
Step 1: Create an empty ASP.NET Web Application in Visual Studio as shown below,





Step 2: Then add an empty model as shown below,



Step 3: Then, add the Model and entity as shown below,



Step 4:
Add the properties that you want in the model by right clicking on the properties field as shown below,

Add

Step 5: After completion of adding the required properties you must generate the database from model as shown below,

properties





Step 6: A dialog box will appear where you have to choose the database name. You can use the already-made database or you can create one from there as well. I am making the new database "CollegeStudent."





Step 7: Another box will appear; do as shown below. That automatically sets up the necessary connection strings for the connection with the database.





Step 8: Dialog box  will automatically close and you will be redirected to visual studio to execute the connections for .edmx as below,



Step 9: Now add the controller inside the controller folder as shown below,



Step 10: Choose MVC 5 Controller with views, using Entity Frame Work as below,



Step 11: Choose the Model name that you made when making the entity, also choose the context name that you made earlier and enter the content name that you want. In my case, I have done it as shown below,



Step 12: Go to RouteConfig inside App_Start and change the controller name to the one that you made earlier and enter the action method name that you want to call when the page loads. In my case, I have done it as shown below,

code

Step 13: Finally, run it in the browser. then you will get the view as shown below. Now you can create, add, and delete the menu from there and go through it for proper operation as you need.

 

output
Thank you for your time! Keep visiting my profile for more blog posts.