Entity framework core IAsyncEnumerable不能用于IEnumerable类型的参数

Entity framework core IAsyncEnumerable不能用于IEnumerable类型的参数,entity-framework-core,entity-framework-core-2.2,Entity Framework Core,Entity Framework Core 2.2,我有实体、服务和视图模型。我在服务中使用服务模型,在服务中我从实体映射到服务模型,并返回IQueryable,我在控制器中使用服务,但当我尝试具体化结果并将其映射到视图模型时,选择它抛出异常: ArgumentException:类型为“System.Collections.Generic.IAsyncEnumerable1[TestDriveServiceModel]”的表达式不能用于方法“System.Collections.Generic.IEnumerable1[TestDriveSer

我有实体、服务和视图模型。我在服务中使用服务模型,在服务中我从实体映射到服务模型,并返回IQueryable,我在控制器中使用服务,但当我尝试具体化结果并将其映射到视图模型时,选择它抛出异常:

ArgumentException:类型为“System.Collections.Generic.IAsyncEnumerable1[TestDriveServiceModel]”的表达式不能用于方法“System.Collections.Generic.IEnumerable1[TestDriveServiceModel]”的类型为“System.Collections.Generic.IEnumerable1[TestDriveServiceModel]ToList[TestDriveServiceModel]System.Collections.Generic.IEnumerable1”的参数[TestDriveServiceModel]' 参数名称:arg0


是在.NET Core 3和C 8中添加的。EF Core 2.2未使用它。引发此异常的位置是什么?请发布引发此异常的实际代码以及从exception.ToString返回的完整异常文本。全文包含调用堆栈和任何内部异常。在任何情况下,错误都会向constru报告无效参数ctor。您发布的代码中没有此类代码。请发布实际引发此异常的代码。添加到.NET Core 3和C 8中。EF Core 2.2未使用此代码。引发此异常的位置是哪里?请发布引发此异常的实际代码以及从exception.ToString返回的完整异常文本。全文包含调用堆栈和任何内部异常。在任何情况下,错误都会向构造函数抱怨参数无效。您发布的代码中没有此类代码。请发布实际引发此异常的代码。
// the service map from entities to service models and returns them
// userServiceModels is the result of the service
// Here the error is thrown
var viewModel = await userServiceModels.Select(usm => new UserViewModel()
{
    TestDrivesCount = usm.TestDrives.Count()
}).ToListAsync();
public class UserServiceModel : IdentityUser
    {
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public ICollection<TestDriveServiceModel> TestDrives { get; set; } = new List<TestDriveServiceModel>();
    }
public class TestDriveServiceModel
    {
        public string Id { get; set; }

        public string CarId { get; set; }
        public CarServiceModel Car { get; set; }

        public string UserId { get; set; }
        public UserServiceModel User { get; set; }

        public string StatusId { get; set; }
        public StatusServiceModel Status { get; set; }

        public DateTime ScheduleDate { get; set; }

        public string Comment { get; set; }
    }
public class User : IdentityUserEntity
    {
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public ICollection<TestDriveEntity> TestDrives { get; set; } = new List<TestDriveEntity>();
    }
public class TestDriveEntity
    {
        public string Id { get; set; }

        [Required]
        public string CarId { get; set; }
        public BaseCarEntity Car { get; set; }

        [Required]
        public string UserId { get; set; }
        public User UserEntity { get; set; }

        [Required]
        public string StatusId { get; set; }
        public Status StatusEntity { get; set; }

        [Required]
        public DateTime ScheduleDate { get; set; }

        public string Comment { get; set; }
    }