我已经扩展了IdentityUser
,将用户地址作为导航属性包含在内。但是当使用UserManager.FindByEmailAsync
获取用户时,导航属性没有填充。ASP.NET Identity Core是否有像Entity Framework的Include()
一样填充导航属性的方法,还是我需要手动完成?
我是这样设置导航属性的:
public class MyUser : IdentityUser
{
public int? AddressId { get; set; }
[ForeignKey(nameof(AddressId))]
public virtual Address Address { get; set; }
}
public class Address
{
[Key]
public int Id { get; set; }
public string Street { get; set; }
public string Town { get; set; }
public string Country { get; set; }
}
[ForeignKey(nameof(AddressId))]
不是必需的。 - Camilo Terevinto