为 ASP.NET IdentityUser 创建多个密钥
Create Multiple Keys for ASP.NET IdentityUser
我正在创建一个多租户应用程序 (MVC) 并正在使用 Identity。在我的IdentityUser
class中,我为租户标识符添加了一个属性:
public Guid TenantId { get; set; }
默认情况下,Id 属性 是键(转换为数据库中的 Id 列)。我想将 TenantId 添加到主键,以便可以有多个用户具有相同的用户名,但会有不同的 TenantId。有人可以解释如何在模型 class 中执行此操作吗?下面是我的示例 class:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public Guid TenantId { get; set; }
}
我找到了多种解决方案,但最终,我最终使用了这张海报的设计:
https://www.scottbrady91.com/ASPNET-Identity/Quick-and-Easy-ASPNET-Identity-Multitenancy
我正在创建一个多租户应用程序 (MVC) 并正在使用 Identity。在我的IdentityUser
class中,我为租户标识符添加了一个属性:
public Guid TenantId { get; set; }
默认情况下,Id 属性 是键(转换为数据库中的 Id 列)。我想将 TenantId 添加到主键,以便可以有多个用户具有相同的用户名,但会有不同的 TenantId。有人可以解释如何在模型 class 中执行此操作吗?下面是我的示例 class:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
return userIdentity;
}
public Guid TenantId { get; set; }
}
我找到了多种解决方案,但最终,我最终使用了这张海报的设计:
https://www.scottbrady91.com/ASPNET-Identity/Quick-and-Easy-ASPNET-Identity-Multitenancy