天天看點

ABP模闆項目,資料庫改為MySQL

開發工具 vs2022 社群版

ABP 選擇 asp.net core 3.x

MySQL版本為 8.0.29

1.本地确認mysql版本和nuget版本相容

删除原本.EntityFrameworkCore 項目的sql server包,下載下傳新的

Pomelo.EntityFrameworkCore.MySql 3.2.3

Pomelo.EntityFrameworkCore.MySql.Design 1.1.0

然後修改

DbContextConfigurer 檔案的

public static void Configure(DbContextOptionsBuilder<demoAbpDbContext> builder, string connectionString)
        {
            builder.UseMySql(connectionString);
        }

        public static void Configure(DbContextOptionsBuilder<demoAbpDbContext> builder, DbConnection connection)
        {
            builder.UseMySql(connection);
        }
           

更改三個appsetting.json檔案資料庫連結,改為自己的mysql

Migrator/

host/

mvc/

"Default": "Server=localhost; Database=abpTest;UID=root;PWD=root;port=3308;Convert Zero DateTime=True"
           

2.删除EntityFrameworkCore/Migrations檔案夾下全部檔案

整體解決方案,右鍵,還原nuget

libman.json 右鍵,還原庫

并且勾選 生成時禁用用戶端庫

3.工具,nuget包管理,程式包管理控制台

選擇EntityFrameworkCore項目

執行

//添加遷移檔案

Add-Migration ***備注

//執行遷移

update-database

啟動host是swagger

啟動mvc是界面

預設登入使用者 admin
預設密碼 123qwe