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

时间:2017-04-02 03:35:15

标签: c# asp.net-mvc entity-framework-6

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;}
  ......
  ......
}

如何以EF6代码第一种方式以上述方式扩展AspNetUser表?

1 个答案:

答案 0 :(得分:1)

也许,ForeignKey属性可以帮助您:

public string UserId {get; set;}

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