Lab - 03 - ProductManagement - Using - SignalR and Entity Framework
Lab - 03 - ProductManagement - Using - SignalR and Entity Framework
Introduction
Imagine you're an employee of a product retailer named Product Store. Your
manager has asked you to develop a web application for product management
Product (ProductID, ProductName, Category, Quantity, Price). The application
has to support adding, viewing, modifying, and removing products—a
standardized usage action verbs better known as Create, Read, Update, Delete
(CRUD).
Lab Objectives
In this lab, you will:
Use the Visual Studio.NET to create ASP.NET Core Web Application
Project.
Develop application using MVC Pattern.
Use Entity Framework to Create a SQL Server database named
SignalRLab that has a Product table.
Develop Entity Classes a and DBContext class to perform CRUD actions
using Entity Framework Core.
Apply JavaScript library for Real-Time communication application.
1|Page
Run the project and test the application actions.
2|Page
Activity 01: Create Project
Create a Solution named SignalRLab. Create ASP.NET Core Web Application
(Model-View-Controller). Open the Visual Studio .NET application and performs
steps as follows:
Create ASP.NET Core Web App (Model-View-Controller)
3|Page
The structure of ASP.NET Core Web Application Project “SignalRLab”.
4|Page
Activity 02: Work with Entity Framework
Step 01. Install the following packages from NuGet:
5|Page
"DefaultConnection": "Persist Security Info=False;User
ID=sa;Password=1234567890;Initial Catalog=SignalRLabDB;Data Source=.;Connection
Timeout=100000"
}
}
6|Page
Step 05. Add ProductsController with Scraffolding
7|Page
8|Page
Activity 03: Create SignalR Hub and configure SignalR
Step 01. Create SignalR Hubs in the SignalrServer.cs
9|Page
10 | P a g e
Activity 04: Build CRUD functions with SignalR
Step 01. Add Client-Side Library
11 | P a g e
12 | P a g e
Step 02. Create a callback function in the script (site.js)
13 | P a g e
14 | P a g e
Step 04. Add SignalR JavaScript client to View
Views/Shared/_Layout.cshtml
15 | P a g e
Views/Products/Index.cshtml
16 | P a g e
Activity 05: Build and run Project. Test all CRUD
actions
17 | P a g e
Client 1 Client 2
18 | P a g e