CRUD (Create, Read, Update, Delete) in asp.net MVC 5 using ADO.Net
In MVC a default approach for database operations in Entity framework. but we can also use an ADO.NET for CRUD operation in this article we will learn how to do CRUD with ADO.NET in MVC. Create a new web project using visual studio (created in 2015)

Add connection to your database in web config
1 | <connectionStrings> |
1 | CREATE TABLE [dbo].[Employee]( |

Add class Extensions to your project (DAL Folder)
1 | using System; |
Add class MyConnection to your project (DAL Folder)
1 | using System; |
Add an Interface IDbCommon to your project (DAL folder)
1 | using System; |
Add class TEmployee to your project (Models folder)
All the properties in a class should be checked with sql server table. (datatype and name should be same). the TEmployee structure in my case is the following.
1 | using System; |
Add class EmployeeDAL to your project (DAL folder)
1 | using System; |
Add controller EmployeeController to your project
1 | using System; |
Add view to index action method
Index view should be look like this
1 | @model IEnumerable<MVC_CRUD_ADO.Models.TEmployee> |
Add view to create action method
create view should be look like this
1 | @model MVC_CRUD_ADO.Models.TEmployee |
Add view to DeleteConfirm action method
DeleteConfirm view should be look like this
1 | @model MVC_CRUD_ADO.Models.TEmployee |
Edit view should be look like this
1 | @model MVC_CRUD_ADO.Models.TEmployee |
0 Comments