Reputation: 103
What is the best practice when it comes to extending/adding properties to the AspNetUsers table? (.Net Core 2.0)
1) You can add additional properties in the AspNetUsers table
2) You can put things in claims
3) You can put a reference to another table in a property
4) You can use the user.id and store that in another table along with more data
So what is the best practice?
Upvotes: 1
Views: 232
Reputation: 239250
Well, #1 and #2 are both acceptable, depending on the particular circumstance. However, #3 and #4 are bad practices which should be avoided. That's similar to the mechanisms ASP.NET Membership utilized with UserProfile
, but that was only necessary because User
was a fixed entity that could not be manipulated. Identity was designed to be extensible, so extend it.
In terms of deciding whether to go with properties or claims, it depends mostly on the type of data. If you're talking about things like FirstName
, LastName
, etc. - things that are equally applicable to every user - I'd go with properties. Conversely, I'd use claims for things like a Facebook access token and such. Storing this on the AspNetUsers
table would result in denormalization of your database, since a lot of users would simply have NULL for that column. A claim is designed by nature to be user-specific and transient.
Upvotes: 7