问题
I added a new property and its corresponding table to my database using ASP.NET Identity with Code First like so:
public class ApplicationUser : IdentityUser
{
....
public virtual ICollection<File> Files { get; set; }
}
public class File
{
..
public virtual ApplicationUser UserManager { get; set; }
}
Now, from some action, when I call:
var user = await UserManager.FindByIdAsync(userid);
it does get the user with the correct userid
I want to Include method in Entity Framework to include the navigational property or relation named File (of type File) 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?
I'm trying replace code
var user = await UserManager.Include(u => u.Files).FindByIdAsync(userid);
来源:https://stackoverflow.com/questions/34941521/how-do-i-tell-usermanager-findbyidasyncuserid-to-include-a-relation