Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug creating scaffolding in VS 2022 #26592

Closed
hcprobst opened this issue Jul 29, 2022 · 3 comments
Closed

Bug creating scaffolding in VS 2022 #26592

hcprobst opened this issue Jul 29, 2022 · 3 comments
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@hcprobst
Copy link

[Enter feedback here]
Whenever I try to add a scaffold to my controllers I get an error message and am unable to add the needed items

Finding the generator 'controller'...
Running the generator 'controller'...
Minimal hosting scenario!
Generating a new DbContext class 'TuitionWaiver.Data.TuitionWaiverContext'
Object reference not set to an instance of an object.
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)

I had the same issues trying to do this in the RazorPagesMovie60 tutorial.

I need this to work please

Suggestions?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Jul 29, 2022
@wadepickett
Copy link
Contributor

wadepickett commented Jul 29, 2022

@hcprobst, it sounds like either one of the packages that are required are not there, the wrong version or you might have an outdated global tool that you have to actually remove, before updating.

Try the following:

Verify the tool versions you have by running the following at the command line:
dotnet tool list -g

You should see the following result with this version or higher (this tutorial does not use preview versions such as for 7.0):
dotnet-aspnet-codegenerator 6.0.6 dotnet-aspnet-codegenerator
dotnet-ef 6.0.6 dotnet-ef

Before installing the latest of the dotnet tool dotnet-ef you need to first uninstall it:
dotnet tool uninstall dotnet-ef --global

Verify your list of installed packages and their version for your MvcMovie project, at the project directory, with the following command:
dotnet list MvcMovie.csproj package --verbosity d

It is possible you might need to start over with a new project in the tutorial since we don't know what state it is in, but try what I suggested above first.

Another possibility is that when running the commands to install packages at the command line, if you paste in several commands to install at once and hit return, you can still need to hit return one more time for the very last line to run, otherwise you are missing that last package. It is easy to miss.

I will close this issue. For more troubleshooting you can try the community at stackoverflow.com. Feel free to reopen this issue if you have more information and feel there is a change that needs to occur in the doc instead. Thanks very much for your feedback. Always appreciated.

@wadepickett
Copy link
Contributor

I updated the instruction above with version information.

@hcprobst
Copy link
Author

hcprobst commented Aug 1, 2022

[Enter feedback here] Whenever I try to add a scaffold to my controllers I get an error message and am unable to add the needed items
See below for more errors
thanks a lot
Finding the generator 'controller'... Running the generator 'controller'... Minimal hosting scenario! Generating a new DbContext class 'TuitionWaiver.Data.TuitionWaiverContext' Object reference not set to an instance of an object. at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0() at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args) at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args) at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)

I had the same issues trying to do this in the RazorPagesMovie60 tutorial.

I need this to work please

Suggestions?

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

* ID: 1d975a83-1550-b284-d0d8-7fe2ea206ff5

* Version Independent ID: 48e81b42-7c2b-afbf-71e6-d4f442a4bd1f

* Content: [Part 4, add a model to an ASP.NET Core MVC app](https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/adding-model?view=aspnetcore-6.0&tabs=visual-studio)

* Content Source: [aspnetcore/tutorials/first-mvc-app/adding-model.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/first-mvc-app/adding-model.md)

* Product: **aspnet-core**

* Technology: **aspnetcore-tutorials**

* GitHub Login: @Rick-Anderson

* Microsoft Alias: **riande**

I added the packages as you said and still get the same error, object not found.

There is definitely an issue with the documentation in that it doesn't say anything about adding the codegenerator or ef packages.

Now I wonder if I may be missing other packages.

I have

PM> dotnet list TuitionWaiver.csproj package --verbosity d
Project 'TuitionWaiver' has the following package references
[net6.0]:
Top-level Package Requested Resolved

Microsoft.EntityFrameworkCore.Design 6.0.7 6.0.7
Microsoft.EntityFrameworkCore.SqlServer 6.0.7 6.0.7
Microsoft.EntityFrameworkCore.Tools 6.0.7 6.0.7
Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.7 6.0.7

I continue to get the error message

Finding the generator 'controller'...
Running the generator 'controller'...
Minimal hosting scenario!
Generating a new DbContext class 'Tuition_Waiver.Data.Tuition_WaiverContext'
Object reference not set to an instance of an object.
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)

I get this when I try to build at the command line

PM> dotnet build TuitionWaiver.csconfig scaffold
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1008: Only one project can be specified.
Full command line: 'C:\Program Files\dotnet\sdk\6.0.302\MSBuild.dll -maxcpucount -verbosity:m -restore -consoleloggerparameters:Summary TuitionWaiver.csconfig scaffold -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\6.0.302\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\6.0.302\dotnet.dll'
Switches appended by response files:
Switch: scaffold

For switch syntax, type "MSBuild -help"
PM> dotnet build scaffold
Microsoft (R) Build Engine version 17.2.0+41abc5629 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1009: Project file does not exist.
Switch: scaffold
PM>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

3 participants