close

前言:

應用ASP.NET MVC (Authentication and Authorization in ASP.NET Web API) 做註冊,加密提升了安全性

但是要增加欄位卻出現錯誤!

由於建立了資料庫,支援 'ApplicationDbContext' 內容的模型已經變更。請考慮使用 Code First 移轉來更新資料庫 (http://go.microsoft.com/fwlink/?LinkId=238269)。

解決辦法:

Step 1: 選擇工具->NuGet封裝管理員->套件管理器主控台,輸入“Enable-Migrations”

Step 2: 資料夾 Models/IdentityModels.cs 即可加上自己的欄位名稱

Step 3: 輸入“Add-Migration "員工代號"”

Step 4: 輸入PM> Update-Database

即完成資料庫新欄位的建立

Step 6: 在介面中增加欄位

Step 5: Controller.cs 即可取得介面上輸入的資料內容

 

參考文章

https://forums.asp.net/t/2085585.aspx?ASP+NET+Identity+Add+New+field+to+Registration+page+Webforms+not+MVC

http://stackoverflow.com/questions/38647335/how-to-add-additional-fields-to-register-page-in-asp-net-mvc

arrow
arrow
    全站熱搜

    程式小試身手 發表在 痞客邦 留言(0) 人氣()