From 0b3af96a0430ad9305f5ad420068ca6a95f74195 Mon Sep 17 00:00:00 2001 From: hello Date: Tue, 27 Feb 2024 15:16:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes/helloshop/identity.md | 56 +++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 notes/helloshop/identity.md diff --git a/notes/helloshop/identity.md b/notes/helloshop/identity.md new file mode 100644 index 0000000..965f4a6 --- /dev/null +++ b/notes/helloshop/identity.md @@ -0,0 +1,56 @@ +# 身份认证系统 + +## 在 Docker 中 启动 PostgreSQL 数据库 + +https://www.postgresql.org + +```shell +docker pull postgres +docker run --name postgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres +``` + +## 使用 PgAdmin 连接 PostgreSQL 数据库 + +https://www.pgadmin.org + +## EfCore 使用 PostgreSQL 数据库 + +```shell +dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL +``` + +## 使用 EfCore 存储 Identity + +```shell +dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore +``` + +## 迁移数据库 + +```shell +dotnet tool install --global dotnet-ef +dotnet add package Microsoft.EntityFrameworkCore.Design +``` + +```shell +dotnet ef migrations add InitialCreate --output-dir EntityFrameworks/Migrations +dotnet ef database update +``` + +## PostgreSQL 数据库命名约定 + +https://github.com/efcore/EFCore.NamingConventions + +## 删除数据库和迁移 + +```shell +dotnet ef database drop --force +dotnet ef migrations remove +``` + +## 使用脚本迁移 + +```shell +dotnet ef migrations script +``` +