2014-03-31 67 views
1

我最近更新了asp.net的身份,现在我无法登录,因为它说,它需要新的领域,所以我试图重新创建的表和表的用户似乎有一些额外的领域,我基本上不需要。Asp.Net身份禁用某些领域

这些字段是:PHONENUMBER,phonenumberconfirmed,twofactorenabled,等等...我如何可以禁用这些恶魔,并说asp.net身份连看都不看他们?因为如果我删除它们,那么我会收到错误,说它找不到这些字段。

回答

0

你需要的一种做法是你需要实现自己的定制用户存储类,如IdentityUser,UserStore等...你可以找到更多信息here

3

您可以禁用不要在类的DbContext他们忽略映射需要的字段。例如,如果你不想使用******中国和PhoneNumberConfirmed您可以在ApplicationDbContext忽略它们如下

protected override void OnModelCreating(DbModelBuilder modelBuilder) 
    { 
     base.OnModelCreating(modelBuilder); 

     modelBuilder.Entity<ApplicationUser>().Ignore(x => x.PhoneNumber); 
     modelBuilder.Entity<ApplicationUser>().Ignore(x => x.PhoneNumberConfirmed); 
    } 

注意,不映射这些字段会导致不使用使用它们因此错过了这些功能的API 。

+0

如何忽略一个类而不仅仅是属性?例如我根本不需要ApplicationUsers表,因为我想根据Active Directory对用户进行身份验证? –