1

I want to customize IdentityUser to add some attributes and change the key type to int. I tried and followed this Microsoft documentation: https://learn.microsoft.com/de-de/aspnet/identity/overview/extensibility/change-primary-key-for-users-in-aspnet-identity

In the documentation, it says:

In IdentityModels.cs, change the ApplicationUser class to inherit from IdentityUser

However I don't find a IdentityModel.cs in my project. That's why I don't think that this documentaion applies to my Razor-pages web app.

How do I go about changing the IdentityUser key type to int?

Jimmy
  • 864
  • 13
  • 24
  • The (German) documentation for Identity in ASP.NET Core is here: https://learn.microsoft.com/de-de/aspnet/core/security/authentication/identity?view=aspnetcore-2.2 – Mike Brind Jun 06 '19 at 11:16
  • I've subclassed IdentityUser to create my own ApplicationUser class and added custom properties to that. I'm not sure you can change the default key. Is there a specific reason you can't use the default GUID? Otherwise you may need to roll your own classes – Brad Patton Jun 07 '19 at 00:54
  • @BradPatton I just thought it was nicer to have `int` keys so that the database can autoincrement them. When using GUIDs I have to generate and check it's not (by chance) in the database yet. – Jimmy Jun 07 '19 at 06:50
  • @Jimmy For any future reader: While I personally still prefer `int` keys (in most cases), checking whether a GUID key already exists (as per my previous comment) isn't really necessary as per [this](https://stackoverflow.com/a/184897/10758800) S.O. answer – Jimmy Feb 26 '21 at 09:57

0 Answers0