Reputation: 1369
Is it possible to have different profiles for different roles? or do I have to:
Upvotes: 1
Views: 770
Reputation: 597
You can use your identity user like this and then add a new Entity Teacher and Student:
public class User: IdentityUser
{
[Required]
[StringLength(100)]
public string FirstName { get; set; }
[Required]
[StringLength(100)]
public string LastName { get; set; }
public DateTime JoinedOn { get; set; }
public virtual Student Student { get; set; }
public virtual Teacher Teacher { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(
UserManager<User, Guid> manager)
{
// Note the authenticationType must match the one defined in
// CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(
this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
Upvotes: 1
Reputation: 597
You may Create different profile for different role. Suppose you have a User table and you have some roles like student, teacher, administrator. You can create a one to one relation between user and student, user and teacher, user and administrator. Attributes specific for Student keep those in Student table.
Edit1:
So you are right you can create the user with common attributes and other tables with attributes specific to them.
Upvotes: 0