문제

I tried this, but the user always ends up being null:

        ApplicationDbContext db = new Models.ApplicationDbContext();
        var user = db.Users.Find(Context.User.Identity.Name);

        if (user == null)
        {
            caller.displayMessage("Error: User does not exist.");
            return;
        }

So, how do I get the current user? I need to get the user's Id and email address.

도움이 되었습니까?

해결책

Find in EF uses the argument as the key value. I don't think the Name property is the key property and therefore you always get null.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top