ASP.NET Identity remove column from AspNetUsers table

asp.net asp.net-identity c# entity-framework

Question

I want to create columns in the AspNetUsers database in my own method when I use the ASP.NET Identity first code technique. I don't need to have several columns with empty data kept. I only need the columns UserName, SecurityStamp, and Id. The only post I could find is here: Duplication of user names and emails in AspNet Identity 2.0, but it hasn't been liked yet (due to error in Santosh comment).

Can someone please explain how to resolve this?

EDIT: Can you eliminate some of these columns and characteristics at all?

Thanks

1
13
5/23/2017 12:26:38 PM

Accepted Answer

ZZZ_tmp
2
8/29/2014 2:16:41 AM

Popular Answer

You only need to configure your entity OnModelCreating within your context Class as: in order to disregard the fields.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
        base.OnModelCreating(modelBuilder);
        modelBuilder.Entity<IdentityUser>().Ignore(c => c.AccessFailedCount)
                                           .Ignore(c=> c.LockoutEnabled)
                                           .Ignore(c=>c.LockoutEndDateUtc)
                                           .Ignore(c=>c.Roles)
                                           .Ignore(c=>c.TwoFactorEnabled);//and so on...

        modelBuilder.Entity<IdentityUser>().ToTable("Users");//to change the name of table.

}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow