Similar Problem as in Why Identity 2.0 adds a new column in AspNetUserRoles when I extend IdentityUser? My ApplicationUser class:
public class ApplicationUser : IdentityUser
{
public ApplicationUser()
{
Address = new Address ();
}
public string Firstname{ get; set; }
public string Lastname{ get; set; }
public Address Address{ get; set; }
public bool IsActivated { get; set; }
}
And the context:
public class DatabaseContext : IdentityDbContext<ApplicationUser>
{
static DatabaseContext()
{
Database.SetInitializer<DatabaseContext>(null);
}
public DatabaseContext()
: base(nameOrConnectionString: "Archive")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUser>().ToTable("Users").Property(p => p.Id).HasColumnName("Id");
modelBuilder.Entity<ApplicationUser>().ToTable("Users").Property(p => p.Id).HasColumnName("Id");
}
The created columns in table AspNetUserRoles are: UserId, RoleId and IdentityUser_Id. If I assign a role to a user, only UserId and RoleId are filled. If I want to retrieve in which roles a user is, nothing comes back.
What I'm doing wrong?