I have a ASP.NET boilerplate project, and the user's login/register has to be based on OTP code. So there are several redundant fields in User table, including Email and IsEmailConfirmed.
I tried not inheriting my User from abpUser, then got error in my UserManager which inherits from AbpUserManager. Seems like everything is tied to AbpUser and AbpUserBase.
I know I can override AbpUserManager methods, and maybe put some default values for these fields. But is there a clean way to get rid of these fields?
You can use Fluent API in your DbContext's OnModelCreating
method.
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<CustomUser>().Ignore(x => x.Email);
builder.Entity<CustomUser>().Ignore(x => x.EmailConfirmed);
}
This will result in those fields not getting mapped. However they still will be the part of your CustomUser
class, because they are inherited from the IdentityUser
. Note that this can break some methods of the UserManager
(e.g. FindByEmailAsync
).