C#C
C#3y ago
ав

✅ Best practice with EF Core "constants"?

How to work with user groups correctly: I have a User relation that contains the id of the group in which it is located. By default, there are two user roles: User with id 1 and Admin with id 2. There are services that need to know which group a user of these two is in. How to properly organize it? Create a constant with the id of the user role and the id of the admin role and pass it throughout the application? Or create a constant with the name of the role, and each time look for the ID of this role by name? Or are there better ways to deal with this?
Was this page helpful?