.NET Core 8, how can I add properties to user account that contains multiple values?

48 Views Asked by At

I'm slowly learning .NET Core 8, and I'm using Identity with individual user accounts. I've recently learned how to add custom properties to the user account such as FirstName and LastName.

I would like to add a property called departments, however, each user may belong to several departments and so the AspNetUsers database table structure will not do. Ideally, I would have a separate table for departements (Deptid, DeptName) and another table for users in those departements (userId, DeptId) that can have multiple entries.

I know how to create such tables manually using SQL Server Management Studio and how to write the queries, but I am wondering if there is a way to add this with migrations and also have the usermanger return a list of departments for the user.

Can someone point me in the right direction. I'm not exactly sure what to even search for.

I am looking for information on this topic.

0

There are 0 best solutions below