C
C#9mo ago
Mihail Mihov

Do I add my Models in the IdentityDbContext from the template?

I'm trying to create a project, where I'll have two types of users (regular and admin) and I'll have a bunch of other models. I am using asp.net core 8 and created my project with the blazor --auth Individual options. It generated for me an ApplicationDbContext which inherits from IdentityDbContext. Should I add my DbSets in this class or should I use a separate context? Ideally I'd want to have separate levels of access for the different user types.
2 Replies
mindhardt
mindhardt9mo ago
You add dbsets to existing context class if it is the same database And access control is not a db thing, more like Identity/AuthZ IMO you should not make the admin model different from the regular user model, this is solved with Roles/Claims In other words, admin is a regular user but with Admin role IdentityDbContext is a regular DbContext but with some predefined tables
Mihail Mihov
Mihail MihovOP9mo ago
Okay thank you. Just using roles does sound much cleaner and I only have one database so I'll just add the DbSets in this IdentityDbContext.
Want results from more Discord servers?
Add your server