I have an extended IdentityUser class which contains a reference to another entity on my DB, but whenever I try to get the User with the UserManager, the referenced entity always comes empty:
My implementation of the User class
public class Usuario : IdentityUser
{
public int ClienteID { get; set; }
public virtual Cliente Cliente { get; set; }
}
A controller that uses the referenced property on the user
[Authorize]
[HttpGet]
public async Task<Direccion> GET()
{
var usuario = await UserManager.FindByNameAsync(Context.User.Identity.Name);
// Cliente will always be null
return usuario.Cliente.Direccion;
}
I also tried removing the virtual keyword from the reference, so that it is lazy loaded, but I'm not sure that is already implemented on EF7.
Any ideas on how to achieve this?