title: IEnumerable<Movies> does not contain definition for FirstOrDefaultAsync()
body: <p>Here is my error message:
  'IEnumerable' does not contain a definition for 'FirstOrDefaultAsync' and no accessible extension method 'FirstOrDefaultAsync' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?)</p>
  
  <p>I have done the following and the error persists:</p>
  
  <ol>
  <li><p>I did not forget to use await, as per this link: <a href="https://stackoverflow.com/questions/42321055/task-does-not-contain-a-definition-for-firstordefault">Task does not contain a definition for &#39;FirstOrDefault&#39;</a></p></li>
  <li><p>I referenced Sytem.Core and imported both System.Linq and System.Data.Entity.(System.Linq is ambiguous/grey so it is not being used), as per this link: <a href="https://stackoverflow.com/questions/32855311/dbset-doesnt-contain-definition-for-firstordefault">DbSet doesn&#39;t contain definition for FirstOrDefault?</a></p></li>
  </ol>
  
  <p>Here's my .cshtml.cs Code, where the error is being generated (line 34):</p>
  
  <pre><code>using System.Collections.Generic;
  using System.Linq;
  using System.Data.Entity;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  using Microsoft.AspNetCore.Mvc.RazorPages;
  using Microsoft.EntityFrameworkCore;
  using Movies.Models;
  
  namespace Movies.Pages.MediaDetails
  {
      public class DetailsModel : PageModel
      {
          private readonly Movies.Models.MoviesContext _context;
  
          public DetailsModel(Movies.Models.MoviesContext context)
          {
              _context = context;
          }
  
          MovieDataAccessLayer objmovie = new MovieDataAccessLayer();
  
          public Movies Movies { get; set; }
  
          public async Task&lt;IActionResult&gt; OnGetAsync(byte? id)
          {
              if (id == null)
              {
                  return NotFound();
              }
  
              Movies = await objmovie.MovieByMedia(id).FirstOrDefaultAsync(m =&gt; m.MediaTypeID == id);
  
              if (Movies == null)
              {
                  return NotFound();
              }
              return Page();
          }
      }
  }
  </code></pre>
  
  <p>Here's my DataAccessLayer, which is being reference by the code above and returns IEnumerable.</p>
  
  <pre><code>using System.ComponentModel.DataAnnotations;
  using System.Data;
  using System.Data.Entity;
  using System.Data.SqlClient;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace Movies.Models
  {
      public class MovieDataAccessLayer
      {
          string connectionString = "Server=servername;Database=DatabaseMovies;Trusted_Connection=True;MultipleActiveResultSets=true";
  
          public IEnumerable&lt;Movies&gt; MovieByMedia(byte? MediaID)
          {
              List&lt;Movies&gt; lstmovie = new List&lt;Movies&gt;();
  
              using (SqlConnection con = new SqlConnection(connectionString))
              {
                  SqlCommand cmd = new SqlCommand("usp_MovieByMedia", con);
                  cmd.Parameters.Add(new SqlParameter("@MediaID", SqlDbType.TinyInt) { Value = MediaID });
                  cmd.CommandType = CommandType.StoredProcedure;
  
                  con.Open();
                  SqlDataReader rdr = cmd.ExecuteReader();
  
                  while (rdr.Read())
                  {
                      Movies movies = new Movies();
  
                      movies.MovieTitle = rdr["MovieTitle"].ToString();
                      movies.MovieYear = Convert.ToInt32(rdr["MovieYear"]);
  
                      lstmovie.Add(movies);
                  }
  
                  con.Close();
  
              }
              return lstmovie;
          }
  
      }
  }
  </code></pre>
  
  <p>Any input would be appreciated.</p>