I'm using ASP.NET Core Identity along with Entity Framework Core on .NET 5, using a code first approach with a postgresql database.
I am trying to extend the identity classes like this
public class User : IdentityUser<int>
{
public ICollection<UserLogin> Logins { get; set; }
}
public class UserLogin : IdentityUserLogin<int>
{
public User User { get; set; }
}
public sealed class AppDbContext : IdentityDbContext<User, Role, int, UserClaim,UserRole, UserLogin, RoleClaim, UserToken>
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
}
However, when I run migrations, the tables that it produces look like this -
Notice that an extra column UserId1 has been created.
I would expect it to recognize that the UserLogin.User navigation's Id should be correspond to the IdentityUserLogin.UserId property (according to the conventions laid out by MS here: https://docs.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key).
I have also tried overriding IdentityUserLogin.UserId but without luck:
public class UserLogin : IdentityUserLogin<int>
{
public User User { get; set; }
public override int UserId { get; set; }
}
Any help would be greatly appreciated. I know that I could probably do a workaround like specifying the mapping manually for these tables, but Id rather figure out how to use the migration tool along with my extended identity classes.
