CRUD Operation With Dapper Using ASP.NET Core 7.0 MVC

R M Shahidul Islam Shahed
5 min readMay 8, 2023

Dapper is a micro-ORM (Object Relational Mapping) framework for .NET that is lightweight, fast, and easy to use. It was created by Sam Saffron of Stack Overflow fame and was designed to provide fast data access for microservices and other lightweight applications.

CRUD Operation With Dapper Using ASP.NET Core 7.0 MVC

Dapper is an extension method-based ORM that allows developers to map SQL query results to strongly typed objects. It is designed to be simple and fast and offers a high degree of flexibility, allowing developers to work with raw SQL queries or build queries using the built-in query builder.

Dapper does not offer the full set of features of larger ORM frameworks like Entity Framework, but it is a good choice for developers who need to execute complex queries quickly and efficiently. Because of its simplicity and speed, Dapper is often used in high-performance applications, such as financial trading systems or real-time data processing applications.

Create New Project Using Visual Studio 2022

Installed Required Packages

dotnet add package Microsoft.Data.SqlClient --version 5.1.1
dotnet add package Dapper.Extensions.NetCore --version 4.2.2

Add Database Connection

  "ConnectionStrings": {
"DefaultConnectionMSSQLNoCred": "Server=DESKTOP-99Q87I2\\MSSQLSERVER2017;Database=DapperCRUD;Trusted_Connection=True;MultipleActiveResultSets=true",
"connMSSQL": "Server=DESKTOP-99Q87I2\\MSSQLSERVER2017;Database=DapperCRUD;User ID=sa;Password=dev123456;TrustServerCertificate=True;MultipleActiveResultSets=true"
}

Database Table Script

/****** Object:  Table [dbo].[Branch]    Script Date: 5/8/2023 1:30:32 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Branch](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](max) NULL,
[Description]…

--

--