我首先使用数据库。我有一个采用者表和一个所有者表。我希望它们都与 AspNetUser 表有关系。最终目标是让用户可以选择注册为采用者还是所有者。
最佳答案
您正在寻找与 AspNetUsers 表的一对多关系 使用以下代码:
public class Owner
{
public int Id { get; set; }
public string Name { get; set; }
public string UserId { get; set; }
[ForeignKey("UserId")]
public ApplicationUser ApplicationUser { get; set; }
}
public class Adopter
{
public int Id { get; set; }
public string Name { get; set; }
public string UserId { get; set; }
[ForeignKey("UserId")]
public ApplicationUser ApplicationUser { get; set; }
}
关于c# - 创建与 AspNetUsers 表的关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58160967/