2017-02-12 67 views
1

我在我的MVC 5項目中使用身份2.0。在asp.net mvc項目中添加列以創建身份表?

當我運行在我的數據庫已經建立了認證和授權的所有默認表項目的第一次:

enter image description here

在AspNetUsers表我需要創建一個名爲整數類型的LoyoutId附加列。

我的問題是如何添加列到創建的默認表?

回答

1

您可以通過在ApplicationUser類中添加更多屬性來爲用戶添加個人資料數據,請訪問this瞭解更多信息。

你的情況:

public class ApplicationUser : IdentityUser 
{ 
    public int LoyoutId { get; set; } 
} 

然後打開包管理器控制檯,並執行以下命令:

PM> Enable-migrations //You don't need this as you have already done it 
PM> Add-migration Give_it_a_name //This will generate a database script file 
PM> Update-database //Run script file against database. 

現在,所有新的屬性就會變成AspNetUsers表。

+0

另請參閱http://www.itorian.com/2013/11/customizing-users-profile-to-add-new.html – Marusyk

+0

感謝post.what如果我需要創建一個表並使其與現有的用戶表? – Michael

+0

不客氣!你什麼意思?沒有幫助我評論的鏈接? – Marusyk

相關問題