【发布时间】:2020-09-21 17:31:49
【问题描述】:
我正在使用 .NET 5 - 版本 5.0.100-rc.1.20452.10。
我自定义表格AspNetUsers成功了,就这样
using Microsoft.AspNetCore.Identity;
using System;
namespace shadow.Models
{
public class ApplicationUser : IdentityUser
{
public string Fullname { get; set; }
public string AliasName { get; set; }
public string SecondMobile { get; set; }
public string About { get; set; }
public string Avatar { get; set; }
public DateTime? Created { get; set; }
public DateTime? Modified { get; set; }
}
}
和
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using shadow.Models;
namespace shadow.Data
{
public partial class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
{
}
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
public virtual DbSet<ApplicationUser> ApplicationUsers { get; set; }
我正在寻找与表 AspNetRoles 类似的解决方案。我需要将文件Description 添加到表AspNetRoles,如何存档?请指导我如何在ApplicationDbContext 中进行更改。
我的努力:我试过了
using Microsoft.AspNetCore.Identity;
namespace shadow.Models
{
public class ApplicationRole : IdentityRole
{
public string Description { get; set; }
}
}
但是错误
将ApplciationRole 转为ApplicationDbContext 时我感觉很难
【问题讨论】:
-
在您配置
ApplicationUser的完全相同的方法调用中,您可以另外配置IdentityRole的类。也许这个问答有帮助? stackoverflow.com/questions/50426278/… -
我更新了信息。将
ApplciationRole转为ApplicationDbContext时我感觉很难 -
错误说明了什么?
-
public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, string>有效吗?其中最后一个参数string是您的身份密钥的类型。
标签: asp.net-core .net-core asp.net-core-identity