question

AliSufian-7874 avatar image
0 Votes"
AliSufian-7874 asked ZhiLv-MSFT answered

AspNetRoleClaim don't have Id as Guid

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>
dotnet-aspnet-core-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ZhiLv-MSFT avatar image
0 Votes"
ZhiLv-MSFT answered

Hi @AliSufian-7874,

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







image.png (38.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.