The error message is too vague
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
## File a bug
Remember:
* Please check that the [documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator?view=aspnetcore-5.0) does not explain the behavior you are seeing.
* Please search in both [open](https://github.com/dotnet/scaffolding/issues) and [closed](https://github.com/dotnet/Scaffolding/issues?q=is%3Aissue+is%3Aclosed) issues to check that your bug has not already been filed.
### Include your code
I can reproduce the issue every time. Just clone my code: https://github.com/doggy8088/VS2022ScaffoldingBug
Here are the steps to reproduce the issue:
1. Open Solution Explorer, Right-click on the Controllers folder, then `Add > Controller`.
2. Choose the item template: `MVC Controller with views, using Entity Framework`
Model class: `Course`
DbContext class: `ContosoUniversityContext`
Hit `Add` button.
3. Then you will see the following error:
> There was an error running the selected code generator: 'Exception of type 'System.InvalidOperationException' was thrown.'

The error message is really too vague. I took 2 hours to figure it out the root cause. I think the error message can be improved.
I also reported this issue there for VS2022: https://developercommunity.visualstudio.com/t/I-wish-there-is-a-feature-that-can-save/10691680?port=1025&fsid=ce2921a1-dd02-402d-8377-b214f05199a5
### Include stack traces
N/A
### Include provider and version information
Microsoft.VisualStudio.Web.CodeGeneration.Design version: `8.0.2`
Target framework: `.NET 8.0`
Operating system: `Microsoft Windows [Version 10.0.19045.4412]`
IDE: `Visual Studio 2022 17.10.3`
Contributor guide
Assessment
This issue has not been assessed yet.