dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.87k stars 4.88k forks source link

ASP.NET Core scaffolding tool #7672

Open mostmate opened 2 years ago

mostmate commented 2 years ago

Description

error generated by running code in visual studio CLI: PM> dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Data.SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries -sqlite dotnet : Scaffolding failed. At line:1 char:1

Could not find project file in C:\Users\awise303\source\repos\ContosoUniversity

############################################################ Alternatively tried manual installation and still get error even after rebuilding project. The following error:

dotnet : Could not find any project in C:\Users\awise303\source\repos\ContosoUniversity\. At line:1 char:1

by following theses steps:

Create a Pages/Students folder. In Solution Explorer, right-click the Pages/Students folder and select Add > New Scaffolded Item. In the Add New Scaffold Item dialog: In the left tab, select Installed > Common > Razor Pages Select Razor Pages using Entity Framework (CRUD) > ADD. In the Add Razor Pages using Entity Framework (CRUD) dialog: In the Model class drop-down, select Student (ContosoUniversity.Models). In the Data context class row, select the + (plus) sign. Change the data context name to end in SchoolContext rather than ContosoUniversityContext. The updated context name: ContosoUniversity.Data.SchoolContext Select Add to finish adding the data context class. Select Add to finish the Add Razor Pages dialog. The following packages are automatically installed:

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

Configuration

Regression?

Other information

buyaa-n commented 2 years ago

CC @Pilchie

Pilchie commented 2 years ago

@vijayrkn - this is your team, right?

vijayrkn commented 2 years ago

Adding @deepchoudhery to help take a look.

deepchoudhery commented 2 years ago

Hmmmm @mostmate Is there a .csproj file in C:\Users\awise303\source\repos\ContosoUniversity\ ? Also confused to the error messages. Are you implying that executing dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design is giving you

  + CategoryInfo          : NotSpecified: (Could not find ...soUniversity\`.:String) [], RemoteException
  + FullyQualifiedErrorId : NativeCommandError

We can move this issue to the scaffolding repo as well.

mostmate commented 2 years ago

There's no .csproj file in C:\Users\awise303\source\repos\ContosoUniversity\ ? I have just reinstalled the software, hoping this works @deepchoudhery

mostmate commented 2 years ago

I entered this code to create a database after scaffolding process

Add-Migration InitialCreate Update-Database

...but got this error (I have just updated the app but no change in response):

Get-Interface : GetEnumerator must be called on the UI thread. At C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\profile.ps1:128 char:20

The following exception occurred while trying to enumerate the collection: "GetEnumerator must be called on the UI thread.". At C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\NUGET\Modules\NuGet\profile.ps1:131 char:5

Add-Migration : You cannot call a method on a null-valued expression. At line:1 char:1