简体   繁体   English

如何将AspNetUser表ID作为外键映射到另一个表

[英]How to map AspNetUser table id as foreign key to another table

public class UserInfo
{
  public int id {get;set;} //Primary key

  public string UserId {get; set;} // Foreign key to AspNetUser - Id

  public string FirstName {get;set;}
  public string LastName {get;set;}
  ......
  ......
}

How can I extend the AspNetUser table in the above fashion in EF6 code first approach? 如何以EF6代码优先方式以上述方式扩展AspNetUser表?

Perhaps, the ForeignKey attribute this will help you: 也许, ForeignKey属性可以帮助您:

public string UserId {get; set;}

[ForeignKey("UserId")]     
public AspNetUser User {get; set;}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将外键添加到 AspNetUser 表 - Add foreign key to AspNetUser table 使用ASPNETUSER表电子邮件字段作为另一个表中的主键,即主外键 - Use ASPNETUSER Table Email Field as a primary key in another table, primary foreign key 使用EF将表的主键映射为AspNetUser表作为外键 - Mapping of primary key of a table into AspNetUser Table as foreign key using EF ASPNETUSER 作为另一个表的子项 - ASPNETUSER as a child to another table 如何使用Code First在ASP.NET MVC 5 Identity 2.0中为AspNetUser表(Id列)在Customer表(CreatedBy列)中添加外键 - How to add a Foreign key in Customer table (CreatedBy column) for AspNetUser table (Id column) in ASP.NET MVC 5 Identity 2.0 using Code First 使用代码优先创建表时添加引用AspNetUser的外键-MVC5 - Adding a Foreign Key referencing AspNetUser when creating a table using Code First - MVC5 从另一个表中给定ID的ASPNetUser表中获取电子邮件列表 - Fetching a list of emails from ASPNetUser table given id from another table 通过另一个控制器将用户添加到aspnetuser表 - Add user to aspnetuser table via another controller 将具有复合键/外键的表映射到该表 - Map table with composite key / foreign key to that table 如何使用Postgresql将值添加到2个表,然后将外键从一个表映射到Entity Framework Core中的另一个表? - How to add values to 2 table then map foreign key from one table to another table in Entity Framework Core using Postgresql?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM