Angular 11 CRUD with .Net 5 REST API Tutorial
Oh crud! How to CRUD?
Announcements:
- On May 12, 2021, Google released Angular version 12. The Angular app in this tutorial has been upgraded from version 11 to 12. You can find the upgraded source code in the ng-12-upgrade branch. The master branch is still at version 11.
- If you are looking for an end-to-end solution, check out the Angular Starter Kit for Rapid Prototype. The starter kit contains boilerplate code for UI/UX, REST API/CRUD, Single-SignOn (SSO), and Identity/Access Management.
Introduction
Imagine you are a developer at a Fortune 500 company. Your new assignment is to build an Angular SPA that searches and updates employee position records. The backend database has 100,000+ records. The requirement is to create a responsive app accessible on desktop, mobile, and tablet. The technology stack is Angular and ASP.NET Core REST API.
Tutorial Content
In this tutorial, I will provide instructions to clone a complete, working, responsive Angular app from Github, set it up on the local, and walk-thru source code pertinent to CRUD. The task is divided into three parts:
Part 1: Clone Angular and WebAPI projects from Github
Part 2: Walk-thru TypeScript CRUD-related code in Angular
Part 3: Walk-thru C# CRUD-related code in NetCore 5
At the end of the tutorial part, I include a complementary screencast so you can see how it was done on my desktop. Grab a drink and relax while watching the video!
Related Tutorials
This tutorial will focus on CRUD-related coding and it does not go into the detail of pagination (filter, sort, paging). To learn pagination, check out my other tutorials.
- Angular 11 Pagination 100,000+ Rows
- NetCore 5 Pagination 100,000+ Rows
- Angular 11 Modal Form, Dialog, and Toaster with Bootstrap
Prerequisites
The following tools and knowledge are recommended
- Visual Code — free code editor for Angular
- Visual Studio 2019 Community — free code editor for C#
- Ability to read Javascript code
- Ability to pronounce C# (c-sharp not c-pound)
Github Repositories
- AngularCrud is the front-end Angular app. The source code for this project was generated by the Ngx-Rocket template. Custom code was added to show (a) data listing and (b) drill-down to detail for editing.
- AngularCrudApi is the backend REST API written in ASP.NET Core 5. The source code for this project was generated by the OnionAPI template and added custom code to support pagination and CRUD.
Live Demo
Developers like to be shown how something works so we can decide whether we want to spend our valuable time learning it. Check out the live demo.
Opensource Project Highlights
rxweb/reactive-form-validators is an Angular validation library with 260+ stars on Github. The library provides all types of complex validation and dynamic validation on Reactive Form, Template Driven Form, and Model-Based Form. The developer is Ajay Ojha who is based in India.
You can show your appreciation to Ajay Ojha by giving a “star” on his Github Repo.
CRUD Overview
In computer programming, create, read, update, and delete (CRUD) are the four basic functions of persistent storage. — Wikipedia
Before diving into the tutorial, let’s get a better understanding of CRUD. CRUD is an acronym for:
CREATE — to add new records via SQL INSERT statement
READ — to retrieve records for display via SQL SELECT statements
UPDATE — to modify records via SQL UPDATE statement
DELETE — to remove records via SQL DELETE statement
CRUD provides logical mapping to low-level database commands. CRUD was not designed to expose API for consumption. For the Angular app, the bridge between CRUD and Database is the REST API.
When programming CRUD, it is important to inform users of the intent and status of data operation. The app source code includes two (2) user-experience features.
- Modal — modal management service that requires users to confirm the data deletion (Figure 1)
- Toaster — toast management service to let users know if the update is successful (Figure 2)


Let’s get started!
Part 1: Clone Angular and WebAPI projects from Github
The objective of the Part 1 tutorial is to clone and run the Angular and REST API on localhost. Refer to Figure 3 for the application architecture diagram.

Task 1.1 — Clone Angular Project
In this task, we are going to clone the Angular project from Github via Command Pallet in Visual Code. Prior to making the clone, be sure to create a folder (C:\apps\devkit\Clients) on your desktop for storing Angular source code.
- Start Visual Code
- Go to menu View>Command Pallete (or Ctrl-Shift-P). See Figure 4 for visual aids.
- Type in “Clone” and select Git: Clone. See Figure 5 for visual aids
- Enter https://github.com/workcontrolgit/AngularCrud when prompt for Provide repository URL or pick a repository source. See Figure 6 for visual aids.
- Select the folder C:\apps\devkit\Clients to save the source code. You should see the AngularCrud project in Visual Studio as shown in Figure 7.
- To restore NPM packages, go to menu View > Terminal (or Ctrl + ‘), type in npm install, and hit Enter. It may take a few minutes to restore the package depending on your network speed. See Figure 8 for visual aids.





Task 1.2 — Clone REST API Project
In this task, we are going to clone the NetCore5 REST API source code from Github using Visual Studio.
The source code for the REST API project is on Github. The solution consists of five projects, structured following the Clean Architecture design pattern. Follow the steps below to open source code:
- Start Visual Studio 2019 and select the option ‘Clone a Repository’
- Clone the repo https://github.com/workcontrolgit/AngularCrudApi to C:\apps\devkit\ApiResources\AngularCrudApi (see Figure 9)

Task 1.3— Run Application
To run the application, start the ASP.NET Core REST API backend first and then the Angular frontend.
Start ASP.NET Core REST API backend
In Visual Studio, run REST API solution by hitting F5. You should see the ASP.NET CORE REST API swagger running on https://localhost:44378/swagger/index.html.
Notice that when you run the solution for the first time, it may take a few minutes to seed 100,000 rows of position test data.
Start the Angular frontend
To run the Angular frontend, from Visual Code > Terminal screen, run ng serve -o to automatically open the Angular app in the browser pointing to URL http://localhost:4200.
After the app is open, you should see the Position table on the Master page. Click on a Position Number to go to the Detail page.
Screencast of Part 1
The complementary Youtube video is a record of the steps in this part of the tutorial. If you find the video helpful, please like and subscribe.











