.NET CoreのIdentityパッケージIdentityUser<Guid>を、単一のクラスで拡張された複数のクラスで使用しようとしていますUserRole。
UserStore<T>ユーザータイプごとに拡張する複数のクラスと、拡張する1つのクラスがありますRoleStore<UserRole>。
以下は私のstartup.csです:
services.AddIdentity<InternalUser, UserRole>(IdentityOptions)
.AddDefaultTokenProviders()
.AddUserStore<InternalUserStore>()
.AddRoleStore<GenericUserRoleStore>();
services.AddIdentityCore<Contractor>(IdentityOptions)
.AddRoles<UserRole>()
.AddDefaultTokenProviders()
.AddUserStore<ContractorUserStore>()
.AddRoleStore<GenericUserRoleStore>();
services.AddIdentityCore<Homeowner>(IdentityOptions)
.AddRoles<UserRole>()
.AddDefaultTokenProviders()
.AddUserStore<HomeownerUserStore>()
.AddRoleStore<GenericUserRoleStore>();
私DbContextは延長していませんIdentityDbContext:
public sealed class EntityDbContext: DbContext { }
複数のエラーが発生したため、以下を追加しましたDbContextが、コメント化しました。
public DbSet<IdentityUserClaim<Guid>> UserClaims { get; set; }
public DbSet<IdentityUserRole<Guid>> UserRoles { get; set; }
さまざまなエラーが発生します。
PluginType IUserStoreのインスタンス 'Dal.IdentityStores.InternalUserStore'およびPluginTypeのインスタンス 'RoleManager'でビルドエラーが発生しましたMicrosoft.AspNetCore.Identity.RoleManager
1[Models.Entities.Users.UserRole] - and Instance 'Dal.IdentityStores.GenericUserRoleStore' for PluginType Microsoft.AspNetCore.Identity.IRoleStore1 [Models.Entities.Users.UserRole]-およびインスタンス 'Dal.IdentityStores.GenericUserRoleStore' PluginType Microsoft.AspNetCore.Identity.IRoleStore1[Models.Entities.Users.UserRole] - and Instance 'Dal.IdentityStores.ContractorUserStore' for PluginType Microsoft.AspNetCore.Identity.IUserStore1 [Models.Entities.Contractors.Contractor] -及びPluginType Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactoryのインスタンス'UserClaimsPrincipalFactory'1[Models.Entities.Contractors.Contractor] - and Instance 'UserClaimsPrincipalFactory<Contractor, UserRole>' for PluginType Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactory1 [Models.Entities.Contractors.Contractor] -およびインスタンス'のUserManager'のPluginType Microsoft.AspNetCore.Identity.UserManager1[Models.Entities.Homeowners.Homeowner] - and Instance 'UserClaimsPrincipalFactory<Homeowner>' for PluginType Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactory1 [Models.Entities.Homeowners.Homeowner]