Add column to aspnetusers with database first

余生长醉 提交于 2019-12-01 18:06:33

OK, I've cracked it! Firstly I didn't realise that although I have moved the Identity tables to the Application database there is still two Database Contexts, one for the application tables which are DB First, and the other for the Identities tables.

I was able to enable migrations and add the column using code first and migrate then update the database. The new column is now available in the controller.

I found this tutorial which helped me: http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx

The easiest solution:

  • Add columns into AspNetUsers table
  • Add properties into IdentityModels.cs class (Check attachment)
  • Add same properties into AccountViewModels.cs\RegisterViewModel class
  • Compile and it will work.

Attachment

(VS 2017, MVC5)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!