title: The provider for the source IQueryable doesn't implement IAsyncQueryProvider
body: <p>I have some codes like below, I want to write unit tests my method. But I'm stuck in async methods. Can you help me please ? </p>
  
  <pre><code>public class Panel
  {
      public int Id { get; set; }
      [Required] public double Latitude { get; set; }
      public double Longitude { get; set; }
      [Required] public string Serial { get; set; }
      public string Brand { get; set; }
  }
  
  public class CrossSolarDbContext : DbContext
  {
      public CrossSolarDbContext()
      {
      }
  
      public CrossSolarDbContext(DbContextOptions&lt;CrossSolarDbContext&gt; options) : base(options)
      {
      }
  
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
      }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
      }
  }
  
  public interface IGenericRepository&lt;T&gt;
  {
      Task&lt;T&gt; GetAsync(string id);
  
      IQueryable&lt;T&gt; Query();
  
      Task InsertAsync(T entity);
  
      Task UpdateAsync(T entity);
  }
  
  public abstract class GenericRepository&lt;T&gt; : IGenericRepository&lt;T&gt;
      where T : class, new()
  {
      protected CrossSolarDbContext _dbContext { get; set; }
  
      public async Task&lt;T&gt; GetAsync(string id)
      {
          return await _dbContext.FindAsync&lt;T&gt;(id);
      }
  
      public IQueryable&lt;T&gt; Query()
      {
          return _dbContext.Set&lt;T&gt;().AsQueryable();
      } 
  
      public async Task InsertAsync(T entity)
      {
          _dbContext.Set&lt;T&gt;().Add(entity);
          await _dbContext.SaveChangesAsync();
      }
  
      public async Task UpdateAsync(T entity)
      {
          _dbContext.Entry(entity).State = EntityState.Modified;
          await _dbContext.SaveChangesAsync();
      }
  }
  
  public interface IPanelRepository : IGenericRepository&lt;Panel&gt; { }
  
  public class PanelRepository : GenericRepository&lt;Panel&gt;, IPanelRepository
  {
      public PanelRepository(CrossSolarDbContext dbContext)
      {
          _dbContext = dbContext;
      }
  }
  
  [Route("[controller]")]
  public class PanelController : Controller
  {
      private readonly IPanelRepository _panelRepository;
  
      public PanelController(IPanelRepository panelRepository)
      {
          _panelRepository = panelRepository;
      }
  
      // GET panel/XXXX1111YYYY2222
      [HttpGet("{panelId}")]
      public async Task&lt;IActionResult&gt; Get([FromRoute] string panelId)
      {
          Panel panel = await _panelRepository.Query().FirstOrDefaultAsync(x =&gt; x.Serial.Equals(panelId, StringComparison.CurrentCultureIgnoreCase));
          if (panel == null) return NotFound();
          return Ok(panel);
      }
  }
  
  public class PanelControllerTests
  {
      private readonly PanelController _panelController;
      private static readonly Panel panel = new Panel { Id = 1, Brand = "Areva", Latitude = 12.345678, Longitude = 98.7655432, Serial = "AAAA1111BBBB2222" };
  
      private readonly IQueryable&lt;Panel&gt; panels = new List&lt;Panel&gt;() { panel }.AsQueryable();
      private readonly Mock&lt;IPanelRepository&gt; _panelRepositoryMock = new Mock&lt;IPanelRepository&gt;();
  
      public PanelControllerTests()
      {
          _panelRepositoryMock.Setup(x =&gt; x.Query()).Returns(panels);
          // I also tried this. I got another error 'Invalid setup on an extension method: x =&gt; x.FirstOrDefaultAsync&lt;Panel&gt;(It.IsAny&lt;Expression&lt;Func&lt;Panel, Boolean&gt;&gt;&gt;(), CancellationToken)'
          // _panelRepositoryMock.As&lt;IQueryable&lt;Panel&gt;&gt;().Setup(x =&gt; x.FirstOrDefaultAsync(It.IsAny&lt;Expression&lt;Func&lt;Panel, bool&gt;&gt;&gt;(), default(CancellationToken))).ReturnsAsync(panel);
          _panelController = new PanelController(_panelRepositoryMock.Object);
      }
  
      [Fact]
      public async Task Register_ShouldInsertOneHourElectricity()
      {
          IActionResult result = await _panelController.Get("AAAA1111BBBB2222");
          Assert.NotNull(result);
          var createdResult = result as CreatedResult;
          Assert.NotNull(createdResult);
          Assert.Equal(201, createdResult.StatusCode);
      }
  }
  </code></pre>
  
  <p>I'm getting this error </p>
  
  <blockquote>
    <p>The provider for the source IQueryable doesn't implement IAsyncQueryProvider. Only providers that implement IEntityQueryProvider can be used for Entity Framework asynchronous operations.</p>
  </blockquote>
  
  <p>I think that I need to mock 'FirstOrDefaultAsync' but I'm not sure and I don't know how to do. I tried something, however it couldn't be compiled.</p>