ASP.NET Identity remove column from AspNetUsers table

后端 未结 5 891
轻奢々
轻奢々 2021-01-31 21:12

When I use ASP.NET Identity first code approach, I want to generate columns in AspNetUsers table in my own way. I don\'t need to have stored multiple columns with null values. I

5条回答
  •  名媛妹妹
    2021-01-31 21:45

    Actually you can ignore the fields, just you need to configure your entity OnModelCreating within your context Class as:

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Entity().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().ToTable("Users");//to change the name of table.
    
    }
    

提交回复
热议问题