I am using ASP.NET Identity 2.2.0 with ASP.NET MVC 5.2.3 and Entity Framework 6.1.2.
I added a new property and its corresponding table to my database using ASP.NET Identity with Code First like so:
public class ApplicationUser
{
[ForeignKey("UserTypeId")]
public UserType Type { get; set;}
public int UserTypeId { get; set;}
}
public class UserType
{
[Key]
public int Id { get; set;}
public string Name { get; set; }
}
Now, from some action, when I call:
var user = UserManager.FindByNameAsync(userName);
It does get the user with the correct UserTypeId
because that is a primitive, but it does not get the UserType
property of the ApplicationUser
class.
If I were not using this abstraction, I would either call LoadProperty<T>
or the Include
method in Entity Framework to include the navigational property or relation named Type
(of type UserType
) on the ApplicationUser
class.
How do I do that with ASP.NET Identity's UserManager
? I suspect the only way would be to override this method in my custom UserManager
derived class and do it myself?