Is it a good idea to manually create columns in existing AspNetUser table?

Viewed 39

I'm using Identity 3 and I want to add some columns in AspNetUser table.

I've tried to do it using EF Core Code first and it's working well but I need to do it DB first.

I was wondering, if I will create the columns manually in database, then create the ApplicationUser class with corresponding properties, will it work?

1 Answers

Yup that should work, I've done it before. However as time goes on I ended up having to add so many that it got messy. So eventually I refactored those extra columns into their own related tables: e.g: User_AdditionalDetails

This was a massive pain as I had live users and had to write scripts to migrate everyone's data etc.

This way you would only need to add a single FK for the related table with all this extra info. It also neatens the code too, and gives the benefit of being able to load different sets of user properties only when they are needed.

If it's for an application scope property of the user like 'Region' which determines behaviour of core functionality of your app, then I'd say add it straight onto the main ApplicationUser class.

Related