对于不同的角色,是否可能有不同的配置文件?还是我必须:
发布于 2015-04-08 09:20:53
您可以像这样使用您的身份用户,然后添加一个新的实体教师和学生:
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;
}
}
发布于 2015-04-07 23:47:48
您可以为不同的角色创建不同的配置文件。假设您有一个用户表,并且您有一些角色,如学生、教师、管理员。您可以在用户与学生、用户与教师、用户与管理员之间建立一对一的关系。特定于学生的属性将这些属性保存在“学生”表中。
Edit1:
因此,您是正确的,您可以创建具有公共属性的用户和具有特定属性的其他表。
https://stackoverflow.com/questions/29508684
复制