【问题标题】:How can i Customize User In Identity 3.1?如何在 Identity 3.1 中自定义用户?
【发布时间】:2020-09-03 07:42:11
【问题描述】:

所以,我想修改我的 User 模型,我想在我的用户模型中添加一个名为 FullName 的新属性(这是一个 string)。

我是Identity 的新手,我不知道我该怎么做。

我正在使用 Razor Pages Web Application 项目并且身份 3.1 工作正常,但我需要向我的用户添加 FullName 属性。

我看过微软的文档和其他一些帖子,但我不明白:(

【问题讨论】:

标签: c# asp.net-core asp.net-identity razor-pages asp.net-core-identity


【解决方案1】:

您必须创建自己的 User 类,比如说 ApplicationUser,它必须扩展 IndentityUser 类,因此带有 FullName 的示例 ApplicationUser 如下所示:

    public class ApplicationUser : IdentityUser
    {
        public string FullName { get; set; }
    }

您可能还需要调整您的DbContext 课程,您能分享一下吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-30
    • 2015-11-03
    • 2020-11-18
    • 2015-07-21
    • 1970-01-01
    • 1970-01-01
    • 2013-11-28
    相关资源
    最近更新 更多