dotnet / dotnet/Scaffolding

.NET Core MVC Scaffold : Please generate also error/not valid model cause

Open
#1,858 7 comments 0 reactions 0 assignees View on GitHub
area-mvc area-scaffolding Needs: Attention :wave: Triage-MoreInfo
Dominant language
C#
Stars
818
Forks
260
Avg merge
1d 8h
Merged PRs (30d)
10

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I use scaffold to create a page using dotnet CLI, and it generate CRUD File. The problem is when the model isn't valid, there're no default view/part of view that show why the model isn't valid to the user like it suppose to

### Describe the solution you'd like

I think it should add error cause like in other framework when scaffold, so beginner can catch pretty quickly when they got looping page without error reason

### Additional context

A simple
```csharp
foreach (var modelState in ViewData.ModelState.Values)
{
TempData["error"] = modelState.Errors;
foreach (ModelError error in modelState.Errors)
{
_log.LogInformation(error.ErrorMessage);
// also on View.cshtml
}
}
```

probably on view should be :
```razor
@foreach(var i in TempData["error"]) {
@i.ErrorMessage
}
```

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.