- You can setup the
DbContext
- inStartup.cs
:
services.AddAdminAspNetIdentityServices<AdminDbContext, UserDto<int>, int, RoleDto<int>, int, int, int,
UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole,
UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>();
- Method
AddAdminAspNetIdentityServices
expects the generic paramTAdminDbContext
that inherits fromIdentityDbContext
and implements interfaceIAdminPersistedGrantIdentityDbContext
(for operation data connected with Asp.Net Core Identity)
- By default, it's used
int
as the primary key, but you can change toGuid
orstring
.
Original:
services.AddAdminAspNetIdentityServices<AdminDbContext, UserDto<int>, int, RoleDto<int>, int, int, int,
UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole,
UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>();
New:
services.AddAdminAspNetIdentityServices<AdminDbContext, UserDto<Guid>, Guid, RoleDto<Guid>, Guid, Guid, Guid,
UserIdentity, UserIdentityRole, Guid, UserIdentityUserClaim, UserIdentityUserRole,
UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>();
2. Change int
to Guid
in all files in folder - Skoruba.IdentityServer4.Admin.EntityFramework/Entities/Identity
:
For example - UserIdentity.cs
:
Original:
public class UserIdentity : IdentityUser<int>
{
}
New:
public class UserIdentity : IdentityUser<Guid>
{
}
- Change
int
toGuid
in other files in this folder -Skoruba.IdentityServer4.Admin.EntityFramework/Entities/Identity
For example - Role.cshtml
:
Original:
@model Skoruba.IdentityServer4.Admin.BusinessLogic.Dtos.Identity.RoleDto<int>
...
@if (!EqualityComparer<int>.Default.Equals(Model.Id, default(int)))
...
New:
@model Skoruba.IdentityServer4.Admin.BusinessLogic.Dtos.Identity.RoleDto<Guid>
...
@if (!EqualityComparer<Guid>.Default.Equals(Model.Id, default(Guid)))
...
- Change
int
toGuid
in other files in this folder -Skoruba.IdentityServer4.Admin/Views/Identity
Original:
public class AdminDbContext : IdentityDbContext<UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>,
IAdminConfigurationDbContext, IAdminLogDbContext, IAdminPersistedGrantIdentityDbContext
New:
public class AdminDbContext : IdentityDbContext<UserIdentity, UserIdentityRole, Guid, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>,
IAdminConfigurationDbContext, IAdminLogDbContext, IAdminPersistedGrantIdentityDbContext
Original:
public class GrantController : BaseController
{
private readonly IPersistedGrantService<AdminDbContext, UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken> _persistedGrantService;
private readonly IStringLocalizer<GrantController> _localizer;
public GrantController(IPersistedGrantService<AdminDbContext, UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken> persistedGrantService,
ILogger<ConfigurationController> logger,
IStringLocalizer<GrantController> localizer) : base(logger)
{
_persistedGrantService = persistedGrantService;
_localizer = localizer;
}
}
New:
public class GrantController : BaseController
{
private readonly IPersistedGrantService<AdminDbContext, UserIdentity, UserIdentityRole, Guid, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken> _persistedGrantService;
private readonly IStringLocalizer<GrantController> _localizer;
public GrantController(IPersistedGrantService<AdminDbContext, UserIdentity, UserIdentityRole, Guid, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken> persistedGrantService,
ILogger<ConfigurationController> logger,
IStringLocalizer<GrantController> localizer) : base(logger)
{
_persistedGrantService = persistedGrantService;
_localizer = localizer;
}
}
Original:
public class IdentityController : BaseIdentityController<AdminDbContext, UserDto<int>, int, RoleDto<int>, int, int, int, UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>
{
public IdentityController(IIdentityService<AdminDbContext, UserDto<int>, int, RoleDto<int>, int, int, int, UserIdentity, UserIdentityRole, int, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken> identityService, ILogger<ConfigurationController> logger, IStringLocalizer<IdentityController> localizer)
: base(identityService, logger, localizer)
{
}
}
New:
public class IdentityController : BaseIdentityController<AdminDbContext, UserDto<Guid>, Guid, RoleDto<Guid>, Guid, Guid, Guid, UserIdentity, UserIdentityRole, Guid, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken>
{
public IdentityController(IIdentityService<AdminDbContext, UserDto<Guid>, Guid, RoleDto<Guid>, Guid, Guid, Guid, UserIdentity, UserIdentityRole, Guid, UserIdentityUserClaim, UserIdentityUserRole, UserIdentityUserLogin, UserIdentityRoleClaim, UserIdentityUserToken> identityService, ILogger<ConfigurationController> logger, IStringLocalizer<IdentityController> localizer)
: base(identityService, logger, localizer)
{
}
}