Adrian
Adrian

Reputation: 3438

Identity 2.0: ApplicationUser extension using a database first approach

From a couple of articles I have found online

http://typecastexception.com/post/2013/10/27/Configuring-Db-Connection-and-Code-First-Migration-for-Identity-Accounts-in-ASPNET-MVC-5-and-Visual-Studio-2013.aspx

http://www.codeproject.com/Articles/790720/ASP-NET-Identity-Customizing-Users-and-Roles

I have seen it is very simple to extend the ApplicationUser class in MVC 5/Identity 2.0. It basically requires adding of property to that class and all dependent views/viewmodels etc to implement the new functionality. The only question I have remaining is due to the fact that these articles all give you examples in regards to a code first perspective. How would extending the Applicationser class work with a database first perspective?

Here is what I imagine.

1.) Change the connection string to your production database. (In my case SQL Azure)
2.) Create the tables that are normally automatically created by identity 2.0 in SQL Azure.
3.) Fill those tables with the default properties and types.
4.) Add custom properties to the AspNetUsers table. (E.G. City, Zip, etc)
5.) Add those properties to the actual ApplicationUser class
6.) Update dependent views, controllers, viewmodels etc.

Is there a more simple way in doing this?

Upvotes: 0

Views: 936

Answers (1)

trailmax
trailmax

Reputation: 35116

No, there is no other way to extend ApplicationUser. Code-First is pretty much the same, only adding properties first, create migration, run migration, update your controllers/views.

Upvotes: 0

Related Questions