Skip to content

An ASP.NET Core Web App project with SQL Server database which performs CRUD operations on multiple tables.

Notifications You must be signed in to change notification settings

ivadham/dotnet-6-razor-pages-crud-project

Repository files navigation

.NET 6.0 Razor Pages CRUD project

An ASP.NET Core application project with ASP.NET Razor Pages content.

Based on BoostMyTool tutorials:

Database creation and connectionString

Create a database with the name of your chioce.

Search the code, replace ALIMPC and URSdatabase with your own Server name and Database name respectively.

Database query

CREATE TABLE users (
  userId INT PRIMARY KEY IDENTITY,
  username VARCHAR (100) NOT NULL,
  email VARCHAR (150) NOT NULL UNIQUE,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE roles (
  roleId INT PRIMARY KEY IDENTITY,
  roleName VARCHAR(50) NOT NULL UNIQUE
);

CREATE TABLE status (
  statusId INT PRIMARY KEY IDENTITY,
  statusName VARCHAR(50) NOT NULL UNIQUE
);

CREATE TABLE userRoles (
  userId INT,
  roleId INT,
  PRIMARY KEY (userId, roleId),
  FOREIGN KEY (userId) REFERENCES users(userId),
  FOREIGN KEY (roleId) REFERENCES roles(roleId)
);

CREATE TABLE userStatus (
  userId INT,
  statusId INT,
  PRIMARY KEY (userId, statusId),
  FOREIGN KEY (userId) REFERENCES users(userId),
  FOREIGN KEY (statusId) REFERENCES status(statusId)
);


INSERT INTO status (statusName)
VALUES
('active'),
('deactive');

INSERT INTO roles (roleName)
VALUES
('su'),
('admin'),
('customer'),
('guest');

INSERT INTO users(username, email)
VALUES
('Bill Gates', '[email protected]'),
('Elon Musk', '[email protected]'),
('Steve Jobs', '[email protected]'),
('Shuhei Yoshida', '[email protected]'),
('John McAfee', '[email protected]'),
('Phil Spencer', '[email protected]');


INSERT INTO userStatus(userId, statusId)
VALUES
(1, 1),
(2, 1),
(3, 2),
(4, 1),
(5, 2),
(6, 1);

INSERT INTO userRoles(userId, roleId)
VALUES
(1, 1),
(2, 2),
(3, 2),
(4, 3),
(5, 4),
(6, 3);

Contributing

For major changes, please open an issue first to discuss what you would like to change.

COPYRIGHT/COPYLEFT

October 2023

About

An ASP.NET Core Web App project with SQL Server database which performs CRUD operations on multiple tables.

Resources

Stars

Watchers

Forks