feat: 重构数据库迁移架构,支持多数据库提供程序 (SQLite/SQLServer/PostgreSQL/MySQL)

- 将迁移文件按数据库类型分目录存放 (Migrations/SQLite, MySQL, PostgreSQL, SqlServer)
- 新增各数据库提供程序的 DesignTimeDbContextFactory,支持 --provider 参数切换
- 新增 ProviderAppDataContexts,定义各数据库对应的 AppDataContext 子类
- DatabaseExtensions 增加 AddProviderAppDataContext 方法,按配置自动注册对应 DbContext
- 修正 MySQL 提供程序调用方式 (UseMySql -> UseMySQL)
- UserEntity 模型增加新字段
- 更新 add-migration.ps1
This commit is contained in:
2026-05-20 16:40:57 +08:00
parent fc6f9f6bc3
commit 1ab9a90831
36 changed files with 2503 additions and 67 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
+2 -2
View File
@@ -14,8 +14,8 @@
"RefreshTokenDays": 30
},
"DatabaseConfiguration": {
"Provider": "SQLite",
"ConnectionString": "Data Source=avalonia-api.db",
"Provider": "MySQL",
"ConnectionString": "Server=127.0.0.1;Port=3306;Database=avalonia-api;Uid=root;Pwd=123456;Max Pool Size=100;Min Pool Size=5;AllowZeroDateTime=True;AllowLoadLocalInfile=true;SslMode=Required",
"AutoMigrate": true,
"RecreateDatabase": false,
"EnableDetailedLog": false,