使用EF核心从todo list删除项目

问题描述 投票:0回答:1

I被要求更新API并从以下代码实现

RemoveToDoItem

[HttpDelete("{id}", Name = "DeleteTodoItem")]
public async Task<IActionResult> RemoveTodoItem(int id)
{
    // TODO
    // Use EF Core to remove the item based on id

    throw new NotImplementedException();
}

这是我尝试运行程序

时获得的错误代码

HttpRequestException:您必须首先实现API端点。 候选人。

} catch (Exception ex) { throw new HttpRequestException("You must first implement the API endpoint."); } throw new HttpRequestException("You must first implement the API endpoint.");
完全不确定如何解决这个问题。我尝试使用

DeleteTodoItem

变量,但没有运气。
    

c# entity-framework todoist
1个回答
1
投票
通过将其添加到构造函数参数中。
    使用您的
  1. DbContext属性上的
    Remove()
  2. 方法标记删除实体。
  3. call
    DbSet<T>
    坚持数据库的更改。
    DbContext
        
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.