IdentityServer4持久化到mysql数据库

复制代码
builder.Services.AddIdentityServer()
//配置存储客户端、资源等到数据库中。
.AddConfigurationStore(options =>
{
    options.ConfigureDbContext = dbBuilder =>
        dbBuilder.UseMySql(strConn, new MySqlServerVersion(new Version(5, 7, 26)),t_builder =>
        t_builder.MigrationsAssembly(migrationsAssembly));
})
//配置用户授权的同意授权的数据、Token等存储到数据库中。
.AddOperationalStore(options =>
{
    options.ConfigureDbContext = dbBuilder =>
        dbBuilder.UseMySql(strConn, new MySqlServerVersion(new Version(5, 7, 26)),t_builder =>
        t_builder.MigrationsAssembly(migrationsAssembly));
})
                .AddDeveloperSigningCredential()
                //.AddInMemoryApiScopes(Config.ApiScopes)
                //.AddInMemoryIdentityResources(Config.GetIdentityResources())
                //.AddInMemoryApiResources(Config.GetApis())
                //.AddInMemoryClients(Config.GetClients())
                .AddTestUsers(Config.GetUsers());
复制代码

 

new MySqlServerVersion(new Version(5, 7, 26))不能少

Add-Migration init -Context ConfigurationDbContext -OutputDir Data/Migrations/IDS4/ConfigurationDb
Add-Migration init -Context PersistedGrantDbContext -OutputDir Data/Migrations/IDS4/PersistedGrantDb
Add-Migration initIdentity -Context AppDbContext -o Data/Migrations/IDS4/AspNetIdentity update
-Database -Context ConfigurationDbContext update-Database -Context PersistedGrantDbContext
update-Database -Context AppDbContext

 

posted @   shiningrise  阅读(213)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2016-07-24 事务环境下的CombGuid
2016-07-24 Productivity Power Tools 是微软官方推出的 Visual Studio 扩展
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css
点击右上角即可分享
微信分享提示