After got this code sample to run successfully, I tried to change the Identity User Id type to Guid:
public class AppUser : IdentityUser<Guid>
{
public string Name { get; set; }
}
I got error in the database context
public class AppIdentityDbContext : IdentityDbContext<AppUser>
{
public AppIdentityDbContext(DbContextOptions<AppIdentityDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
saying:
The type 'AuthServer.Infrastructure.Data.Identity.AppUser' cannot be used as type parameter 'TUser' in the generic type or method 'IdentityDbContext'. There is no implicit reference conversion from 'AuthServer.Infrastructure.Data.Identity.AppUser' to 'Microsoft.AspNetCore.Identity.IdentityUser'
Guessing that Asp.Net Roles are not used by Identity Server in this project, I've tried a workaround by creating an empty AppRole class inheriting from IdentityRole and used it as follows:
public class AppIdentityDbContext : IdentityDbContext<AppUser, AppRole, Guid>
Error stopped showing but after deleted migrations folder and recreated a new initial migration, I've got the following error:
An error occurred while accessing the IWebHost on class 'Program'. Continuing without the application service provider. Error: GenericArguments1, 'Microsoft.AspNetCore.Identity.IdentityRole', on 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken,TRoleClaim]' violates the constraint of type 'TRole'.
So what can be done ?