core icon indicating copy to clipboard operation
core copied to clipboard

ASP.NET Core scaffolding tool

Open mostmate opened this issue 2 years ago • 6 comments

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

  • dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Data.Scho ...
  •   + CategoryInfo          : NotSpecified: (Scaffolding failed.:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    

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

  • dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
  •   + CategoryInfo          : NotSpecified: (Could not find ...soUniversity\`.:String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    
    
    

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

mostmate avatar Aug 07 '22 08:08 mostmate

CC @Pilchie

buyaa-n avatar Aug 08 '22 18:08 buyaa-n

@vijayrkn - this is your team, right?

Pilchie avatar Aug 08 '22 19:08 Pilchie

Adding @deepchoudhery to help take a look.

vijayrkn avatar Aug 08 '22 19:08 vijayrkn

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.

deepchoudhery avatar Aug 08 '22 19:08 deepchoudhery

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

mostmate avatar Aug 09 '22 17:08 mostmate

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

  •     $service = Get-Interface $service $InterfaceType
    
  •                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Get-Interface], COMException
    • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Get-Interface

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

  • $service
    
  • ~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
    • FullyQualifiedErrorId : ExceptionInGetEnumerator

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

  • Add-Migration InitialCreate
  •   + CategoryInfo          : InvalidOperation: (:) [Add-Migration], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull,Add-Migration
    
    

mostmate avatar Aug 09 '22 19:08 mostmate