无法创建 'ElectiveTesting.Models.ApplicationUser' 类型的常量值

Unable to create a constant value of type 'ElectiveTesting.Models.ApplicationUser'

我收到这条消息:

无法创建 'ElectiveTesting.Models.ApplicationUser' 类型的常量值。此上下文仅支持基本类型或枚举类型。

    var thisUser = manager.FindById(User.Identity.GetUserId());
    viewModel.InvitedToElections = db.Elections.Where(e => e.ApplicationUsers == thisUser)
            .Include(e => e.Electives);

我已经阅读了关于这个主题的其他帖子,但没能找到 solution/work。

如果你想获得与特定用户相关的所有选举,你应该使用 Any 运算符:

db.Elections.Where(e => e.ApplicationUsers.Any(au => au.UserId == thisUser.Id))