I tried to test an async
repo method, I mocked dbcontext
, and did same as Microsoft’s documentation suggested (https://learn.microsoft.com/en-us/ef/ef6/fundamentals/testing/mocking?redirectedfrom=MSDN#testing-with-async-queries).
I use .NET 8.0, at the last step
var blogs = service.GetAllBlogsAsync().Result;
I get this error:
System.AggregateException: One or more errors occurred. (The source ‘IQueryable’ doesn’t implement ‘IAsyncEnumerable<TestAsync.Blog>’. Only sources that implement ‘IAsyncEnumerable’ can be used for Entity Framework asynchronous operations.)
Can anyone help? Thanks.
I did exactly the same as Microsoft suggested and searched online, still didn’t work
David Zhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.