dotnet / dotnet/Scaffolding

Why does Minimal API Scaffold generated `PUT` endpoint not update the model properties?

Open
#1,964 4 comments 0 reactions 1 assignee Claimed by @deepchoudhery View on GitHub
area-scaffolding
Dominant language
C#
Stars
818
Forks
260
Avg merge
1d 8h
Merged PRs (30d)
10

Description

The code generated by the Minimal API Scaffolder includes:
- Get all items
- Get item by key
- Update existing item
- Add a new item
- Delete an item

All of them contain the minimal required code to do what is expected, except the **Update existing item** that misses the step to update all the model properties with the new provided value and instead include the comment `//update model properties here`

``` C#
routes.MapPut("/api/SampleModel/{id}", async (int Id, SampleModel sampleModel, SampleModelContext db) =>
{
var foundModel = await db.Samples.FindAsync(Id);

if (foundModel is null)
{
return Results.NotFound();
}
//update model properties here

await db.SaveChangesAsync();

return Results.NoContent();
})
```

Is that the expected behavior? What is the reason behind this decision?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.