2014-10-16 2 views
0

나는 Asp.net Identity를 사용한다. AspnetUserLogins 테이블에 몇 가지 추가 열을 추가하고 싶습니다 (Firstname, Lastname 열).Asp.net Identity, IdentityUserLogins 클래스의 상속

ExternalLoginInfo eInfo = Context.GetOwinContext().Authentication.GetExternalLoginInfo(); 
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>(); 
IdentityResult result = manager.AddLogin(this.User.Identity.GetUserId(), eInfo.Login);` 

모든 것이 잘 작동 : 그하기 위해 나는 UserManager 클래스,이 방법에 의해 특정 사용자에게 외부 로그인을 추가하는 기능을 사용하여 응용 프로그램에서

public class ApplicationUserLogin : IdentityUserLogin 
{ 
public string FirstName { get; set; } 
public string LastName { get; set; } 
} 

같은 클래스 IdentityUserLogins을 물려 받았다. 이 코드는 AspnetUserLogins 테이블에 새 레코드를 추가하고 불행히도 값을 Discriminator 컬럼에 삽입하십시오. UserManager<ApplicationUser> 클래스는 서브 클래스 ApplicationUserLogin 대신 IdentityUserLogin를 사용 (및 "ApplicationUserLogin" 값으로 판별 자 컬럼을 채우기 위해 말을하는 방법을있는 posibility이 있습니까?

답변

0

이 올바른 얻으려면, 다음과 같이 모든 IdentityUserLogin 관련 테이블 및 상속을 업데이트해야합니다.

ApplicationUser :

public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, IdentityRole, IdentityUserClaim> 
{ 

} 

귀하의 DB를 contenxt :

public class YourDataContext : IdentityDbContext<ApplicationUser , IdentityRole, string, ApplicationUserLogin, IdentityUserRole, IdentityUserClaim> 
{  

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


     modelBuilder.Entity<ApplicationUserLogin>().ToTable("TableName"); 

     //Any relevant model bindings. 

    } 
}