I’m currently developing a multi-tenant, single DB web application using ASP.NET Core and Entity Framework Core. I have two kinds of users.
- Customers
- Staffs
Customers are not tied up to any tenant. Staffs can belong to only one tenant and they can have different role such as admin, accountant…. Besides this all their properties are similar. I want to keep customers and staffs data in separate table but not sure if this is the right approach. Should I be placing all the users in the same table (AspNetUsers
) and use roles instead?
I have defined my models like below
public class Customer : IdentityUser
{
// Additional properties specific to Customer
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class Staff : IdentityUser
{
// Additional properties specific to Staff
public int TenantId { get; set; }
public Tenant Tenant { get; set; }
}
And in Program.cs
builder.Services.AddIdentityCore<IdentityUser>()
.AddEntityFrameworkStores<AppDbContext>();
Developer Account is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.