abp快速入门#2
更改生成表的schema
自动生成的IdentityServer相关的表名比较长,可以修改成独立的schema为idsrv.
- 找到Rat.BookStore.EntityFrameworkCore.DbMigrations项目的文件BookStoreMigrationsDbContext.cs中修改代码。
// 更改成独立schema
builder.ConfigureIdentityServer(options=> {
options.Schema = "idsrv";
options.TablePrefix = string.Empty;
});
- 在Windows的命令行执行,生成migration并更新到数据库。
dotnet ef migrations add idsrv
-s D:\my-project\Rat.BookStore\aspnet-core\src\Rat.BookStore.DbMigrator\
Rat.BookStore.DbMigrator.csproj
-p D:\my-project\Rat.BookStore\aspnet-core\src\Rat.BookStore.EntityFrameworkCore.DbMigrations\
Rat.BookStore.EntityFrameworkCore.DbMigrations.csproj
dotnet ef database uddate
-s D:\my-project\Rat.BookStore\aspnet-core\src\Rat.BookStore.DbMigrator\
Rat.BookStore.DbMigrator.csproj
-p D:\my-project\Rat.BookStore\aspnet-core\src\Rat.BookStore.EntityFrameworkCore.DbMigrations\
Rat.BookStore.EntityFrameworkCore.DbMigrations.csproj
数据库表修改前与修改后的对比:
3. 更改后会导致Rat.BookStore.IdentityServer项目失败,经查找abp源码,暴力修复方案,在项目启动Startup强制更改参数(或许有更优雅的方案暂时没找到)。
public void ConfigureServices(IServiceCollection services)
{
AbpIdentityServerDbProperties.DbSchema = "idsrv";
AbpIdentityServerDbProperties.DbTablePrefix = string.Empty;
services.AddApplication<BookStoreIdentityServerModule>();
}