I am following the tutorial for the MVC version of Contoso University at:
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).