dotnet / Scaffolding

Code generators to speed up development.
MIT License
637 stars 228 forks source link

The error message is too vague #2830

Open doggy8088 opened 3 months ago

doggy8088 commented 3 months ago

File a bug

Remember:

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.'

    image

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