I\'ve created an ASP.NET Core Razor Pages application with user identities.
The created project includes a migration that adds all the user tables, such as AspNetU
The default identity uses IdentityUser
, it is not exposed to the project code but you can create a new user model (e.g. AppUser
) that is derived from IdentityUser
, then add the foreign keys to the new user model:
public class AppUser : IdentityUser
{
public int AddressId { get; set; }
public UserAddress Address { get; set; }
}
public class UserAddress
{
public int Id { get; set; }
// ...
public string UserId { get; set; }
public AppUser User { get; set; }
}
Then replace IdentityUser in startup with AppUser :
services.AddDefaultIdentity<AppUser>();
Then create new migrations to create the new user table.