The following project is an ASP.NET Core Web API that talks to a SQL Server database using the micro ORM Dapper.
The API manages a book library, it exposes endpoints for CRUD operations over a Book table.
- Create the Book table in the database
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Books](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Title] [text] NULL,
[Author] [text] NULL,
[Description] [text] NULL,
CONSTRAINT [PK_Books] PRIMARY KEY NONCLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
- Clone the repo
git clone https://github.com/techwithpat/Dapper-with-ASP.NET-Core-Web-API.git
- Update connection string in appsettings.json
"ConnectionStrings": {
"Default": "Your Connection string"
}
- Press F5
ASP.NET Core 5.0
C#
Patrick Tshibanda