CRUD in Asp.net MVC
Microsoft Net Framework

Introduction

 

In this article I will explain how we can make CRUD operations in ASP.Net MVC. In this article we will use a data base first

 approach and perform CRUD operations using entity framework. I hope you like this article and get some information from it.

 

Step-1

Open Visual Studio. Here I use Visual Studio 2019, you can use any one as your system.

 

Step-2

Create a new project by clicking on File>New>Project.

 

Step-3

Select Asp.Net Web Application and click on next button.

 

Step-4

In the next screen you need to enter a few details like your project name, project location where you want to save your project,

 solution name and .Net Framework version. After entering all details click on Create button.

 

Step-5

In Next select MVC project and click on Create button. Now your project is ready and you can see project structure in below image. Here I deleted all view from home controller because we created a new for our requirement.

 

 

Step-6

Now in this project we will use database first approach so we need to create a database and a table. Here I created a database name with Tutorials and table Employee with the  following columns as you can see in the below image.

 

Description: https://csharpcorner-mindcrackerinc.netdna-ssl.com/article/crud-operation-in-asp-net-mvc2/Images/6.PNG

 

Step-7

Now we need to add Entity Framework in our project for performing some operation. For adding Entity Framework click on project name in solution explore then click on Manage NuGet Packages.

 

Step-8

 

Now you see a window with many NuGet Packages. Search for Entity framework and click on install button and after a few seconds Entity Framework is installed in your project.

 

Step-9

 

Now we need to add ADO.Net Entity Data Model in our project. For adding ADO.Net Entity Data Model click on your project name then click on Add and then click on new Item or you can use short cut key Ctrl+Shift+A .

 

Step-10

 

Now you see a popup window. Select ADO.Net Entity Data Model, give appropriate name and click on add button.

Note

There is a change that in visual studio 2019 you cannot see ADO.Net Entity Data Model option. For adding ADO.Net Entity Data Model  in visual studio open visual studio install , select modify option by clicking on more button. Now you see a new window click on Individual Component tab, search for Entity Framework tool then select it and click on modify button.

 

Step-11

 

 

After adding ADO.Net Entity Data Model you will see a popup window. Select EF Designer From database and click on next button.

 

Step-12

 

Now select your database from drop down and give connection string name, and  click on Next button.

 

Step-13

 

Select tables which you want to add in project, here I have only one table so I select that, gave Model Namespace name and Click on finish button.

Share This with your friend by choosing any social account


Upcoming Articles
You may also read following recent Post
Copyright Future Minutes © 2015- 2024 All Rights Reserved.   Terms of Service  |   Privacy Policy |  Contact US|  Pages|  Whats new?
Update on: Dec 20 2023 05:10 PM