I\'ve extended IdentityUser to include a navigation property for the user\'s address, however when getting the user with UserManager.FindByEmailAsync
Unfortunately, you have to either do it manually or create your own IUserStore where you load related data in the FindByEmailAsync method:
public class MyStore : IUserStore, // the rest of the interfaces
{
// ... implement the dozens of methods
public async Task FindByEmailAsync(string normalizedEmail, CancellationToken token)
{
return await context.Users
.Include(x => x.Address)
.SingleAsync(x => x.Email == normalizedEmail);
}
}
Of course, implementing the entire store just for this isn't the best option.
You can also query the store directly, though:
UserManager userManager; // DI injected
var user = await userManager.Users
.Include(x => x.Address)
.SingleAsync(x => x.NormalizedEmail == email);