IdentityServer4 PersistedGrantDbContext&ConfigurationDbContext
问题描述:
身份识别服务器的新手4.我遵循文档上的IdentityServer4 EntityFramework示例here。IdentityServer4 PersistedGrantDbContext&ConfigurationDbContext
迁移脚本运行dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb
后它的工作原理,现在我的申请有3个DB上下文。
- ApplicationDbContext
- PersistedGrantDbContext
- ConfigurationDbContext
我的问题是什么是两个DB上下文的?应用程序数据库上下文和其他两个区别有什么区别?
如果我更新或添加任何模型,是否需要更新所有三个?或者何时应该在ApplicationDbContext上运行迁移,以及何时在另外两个上运行迁移。
任何有关这些的见解或文学表示赞赏。 谢谢。
答
想通了。留下这个让任何人都像我一样对此感到困惑。
有3个数据库上下文,正如@Jasen提到的那样,它是将对实体或表的访问分开。
IdeneityServer4 +的EntityFramework + ASP.NET身份在数据库中创建下表:
上下文被用来引用如下:
ApplicationDbContext - 负责参与ASP用户.NET身份所以表格
- dbo.AspNetRoleClaims 个
- dbo.AspNetRoles
- dbo.AspNetUserClaims
- dbo.AspNetUserLogins
- dbo.AspNetUserRoles
- dbo.AspNetUsers
- dbo.AspNetUserTokens
PersistedGrantDbContext - 负责存储的同意,授权码,刷新标记和引用标记
- dbo.PersistedGrants
ConfigurationDbContext - 负责一切留在数据库
因此,在关于移民,如果我更新任何ASPNET身份识别模型(即ApplicationUser),然后我将在ApplicationDbContext上运行迁移。任何客户端表或其他范围将在ConfigurationDbContext上运行。访问entites(或表)将是相应的上下文。
这个想法是分割实体,所以你只消耗你需要的表,所以应用程序不需要一次性加载所有的表现,也可以限制访问。 https://*.com/questions/11197754/entity-framework-one-database-multiple-dbcontexts-is-this-a-bad-idea – Jasen
@Jasen有道理,谢谢。有关IdentityServer4中如何使用PersistedGrantDbContext和PersistedGrantDbContext的任何见解? –
我不熟悉IdentityServer的详细信息。我认为他们将赠款与应用商店中的服务器配置分开存储。 – Jasen