diff --git a/aspnetcore/tutorials/first-web-api/sample/TodoApi/Controllers/TodoController.cs b/aspnetcore/tutorials/first-web-api/sample/TodoApi/Controllers/TodoController.cs index 14c276a6de..27287400af 100644 --- a/aspnetcore/tutorials/first-web-api/sample/TodoApi/Controllers/TodoController.cs +++ b/aspnetcore/tutorials/first-web-api/sample/TodoApi/Controllers/TodoController.cs @@ -85,7 +85,7 @@ namespace TodoApi.Controllers [HttpDelete("{id}")] public IActionResult Delete(long id) { - var todo = _context.TodoItems.First(t => t.Id == id); + var todo = _context.TodoItems.FirstOrDefault(t => t.Id == id); if (todo == null) { return NotFound();