【问题标题】:How can I connect the AspNetUsers table from Identity with another table?如何将 Identity 中的 AspNetUsers 表与另一个表连接起来?
【发布时间】:2020-11-30 03:36:44
【问题描述】:

AspNetUsers 表有一个我想使用的 Id 列。

这是我想为 AspNetUsers 表创建 fk 的“另一个表模型”:

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;


namespace Project.Models
{
    public class Profile
    {
        public int Id { get; set; }
        public string Type { get; set; }    
        public string BusinessName { get; set; }
        [DataType(DataType.ImageUrl)]
        public string LogoUrl { get; set; }
        public string Status { get; set; }

        [ForeignKey("AspNetUsersId")]
        public virtual ApplicationUser ApplicationUser { get; set; }
    }
}



【问题讨论】:

    标签: asp.net-core entity-framework-core asp.net-identity asp.net-core-3.1


    【解决方案1】:

    我将身份表包含在我的应用程序数据库中,而不是单独的数据库中。只要身份表在您的数据库中,您就可以创建关系。

    【讨论】:

    • 我怎样才能建立关系?
    • 可以参考this
    猜你喜欢
    • 2017-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    • 2023-04-01
    相关资源
    最近更新 更多