Home > Mobile >  What is causing DbSet<T> does not contain a definition for GetAwaiter error message?
What is causing DbSet<T> does not contain a definition for GetAwaiter error message?

Time:01-25

I am following the tutorial for the MVC version of Contoso University at: enter image description here

CodePudding user response:

If you're trying to fetch all courses, you're probably looking for:

var courseToUpdate = await _context.Courses.ToListAsync();

CodePudding user response:

If your code is copied as is - remove extra ;:

var courseToUpdate = await _context.Courses
        .FirstOrDefaultAsync(c => c.CourseID == id);

DbSet itself is not awaitable by itself but contains a lot of operations which return Task which can be awaited (FirstOrDefaultAsync, ToListAsync, etc. see EntityFrameworkQueryableExtensions class).

  • Related