I'm using the below link for mocking the FromSql method in x unit How could I Mock the FromSql() method?
I'm getting the below error for the method which uses FirstOrDefaultAsync
The provider for the source IQueryable doesn't implement IAsyncQueryProvider. Only providers that implement IAsyncQueryProvider can be used for Entity Framework asynchronous operations.
But it is working fine for the ToListAsync
method.
SpAsyncEnumerableQueryable<Model> models = new SpAsyncEnumerableQueryable<Model>();
models.Add(new Model { ItemId = 1 });
MyDbContext.Model = MyDbContext.Model.MockFromSql(models);
Below is the Actual method c#
return await this.MyDbContext.Model
.FromSql("TestProc", 1, 1)
.FirstOrDefaultAsync()
.ConfigureAwait(false);
Getting error at FirstOrDefaultAsync
The provider for the source IQueryable doesn't implement IAsyncQueryProvider. Only providers that implement IAsyncQueryProvider can be used for Entity Framework asynchronous operations.