Nic*_*rra 2 entity-framework dbcontext ef-migrations identityserver4
IdentityServer 4的新手。我在文档中的此处遵循IdentityServer4 EntityFramework示例。
运行迁移脚本后
dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb
Run Code Online (Sandbox Code Playgroud)
它可以工作,现在我的应用程序具有3个数据库上下文。
我的问题是这两个数据库上下文是做什么的?应用程序数据库上下文和其他两个上下文有什么区别?
如果我更新或添加任何模型,是否需要更新所有三个模型?或者什么时候应该在ApplicationDbContext上运行迁移,什么时候应该在其他两个上运行。
对此有任何见识或文献表示赞赏。谢谢。
弄清楚了。像我一样,将其留给对此感到困惑的任何人。
有3个DB上下文,正如@Jasen所提到的,它是为了拆分对实体或表的访问。
IdeneityServer4 + EntityFramework + ASP.NET Identity在数据库中创建以下表:
上下文用于引用以下内容:
ApplicationDbContext-负责与ASP.NET Identity相关的用户,因此表
PersistedGrantDbContext-负责存储同意,授权码,刷新令牌和参考令牌
ConfigurationDbContext-负责数据库中剩余的所有其他内容
因此,关于迁移,如果我更新任何AspNet身份模型(即ApplicationUser),那么我将在ApplicationDbContext上运行迁移。任何客户端表或其他作用域将在ConfigurationDbContext上运行。访问实体(或表)将是相应的上下文。
| 归档时间: |
|
| 查看次数: |
2610 次 |
| 最近记录: |