2014-05-10 46 views

回答

3

您可以簡單地從App_Start文件夾打開數據庫並修改字段。 (如果你使用模板)

+0

我如何讀/寫,從這些代碼字段? – Basil

+0

你確定嗎?該表使用EF Code First創建,它的模式將根據遷移索引進行檢查。那麼你如何制止衝突?\ –

0
public class ApplicationUser : IdentityUser 
{ 
    public string YourProperyHere { get; set; } 

    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) 
    { 
     // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType 
     var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); 
     // Add custom user claims here 
     return userIdentity; 
    } 
} 

更多here

0

提供的Visitor類你作爲一個模板,當你安裝一個新的身份框架項目,該類是聯繫在一起的AspNetUsers表。它繼承了一堆你有弱/無法控制的屬性,然後你可以添加任何你想要的。

public class Visitor : IdentityUser 
{ 
    [MaxLength(300)] 
    public string FirstName { get; set; } 

    [MaxLength(300)] 
    public string LastName { get; set; } 

    public DateTime CreatedOn { get; set; } 


    public Visitor() 
    { 
     CreatedOn = DateTime.UtcNow; 
    } 
} 

我還沒有找到一種方法來修改或甚至直接查詢AspNetUserLogins表,作爲默認的身份框架安裝爲您提供了訪問用戶和角色,但不能登錄分貝。進一步的表格是作爲用戶的一個步驟,但是,這不會讓你查詢它。而且,至少默認情況下,它與Identity Framework附帶的庫存類相關聯;對它進行子類化並讓框架使用該子類可能不在表格中。不知道,值得了自己的問題:

Add Columns/Properties to AspNetUserLogins/Logins in IdentityDbContext

相關問題