AspNetRoleClaim don't have Id as Guid

Ali Sufian 21 Reputation points
2021-04-13T09:13:15.367+00:00

I am using identity when i do migration the table AspNetRoleClaim and AspNetUserClaim do not have Id as Guid both tables have int rest of tables such as AspNetUsers and AspNetRoles have Id as Guid

  ApplicationRoleClaim : IdentityRoleClaim<Guid>
    public class ApplicationUserClaim : IdentityUserClaim<Guid>

    public class ApplicationRole : IdentityRole<Guid>
     public class ApplicationUser : IdentityUser<Guid>


        public class AppDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid,ApplicationUserClaim,ApplicationUserRole,ApplicationUserLogin,ApplicationRoleClaim,ApplicationUserToken>
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,148 questions
0 comments No comments
{count} votes

Accepted answer
  1. Zhi Lv - MSFT 32,011 Reputation points Microsoft Vendor
    2021-04-15T02:35:54.937+00:00

    Hi @Ali Sufian ,

    Please check the definition of the IdentityRoleClaim<Tkey> or the Identity data source. As we can see that, the Tkey is the type of the primary key of the role associated with this claim (the RoleId Property), instead of the Id Property. So, the Id property still is the int type.

    87966-image.png

    Besides, for the Id property, the Identity defines it as an int, if you try to override this property, it will show the ApplicationRoleClaim.Id': type must be 'int' to match overridden member 'IdentityRoleClaim<Guid>.Id' error. So, I suggest you could try to create a new property to store the Guid value.

    ------
    If the answer doesn’t solve your issue, please provide more details of error that will help us track down what’s happening.
    If the answer is helpful, please click "Accept Answer" and vote it up.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards,
    Dillion

    0 comments No comments

0 additional answers

Sort by: Most helpful