Hello everyone! I have a web project in ASP.NET MVC and SQL Server 2019, my app already have a functional user registration and roles system, but i have to assign the roles in Managment Studio manually and then i can change them in a view in my app.
I have these tables:
User: PK UserID - FirstName - LastName - Email
RoleMaster: PK ID - RolName
UserRoleMapping: PK ID - FK UserID - FK RoleID
The RoleMaster table has three roles: Admin (ID 1), User (ID 2), and Guest (ID 3)
I need that everytime a new user registers in the system, the database assign its UserID with the Guest role in the UserRoleMapping table.
There's a way to complete the FK UserID and FK RoleID fields at database-level? Maybe a sql script or a trigger that copies the fields into the UserRoleMapping table after a user registration or something, since i just need the new UserID and RoleMaster ID:3 to be copied into the table.