.net core aspnet codegenerator标识列表选项导致脚手架失败错误

.net core aspnet codegenerator标识列表选项导致脚手架失败错误,.net-core,asp.net-identity,scaffolding,.net Core,Asp.net Identity,Scaffolding,浏览本教程 我所做的一切都是按照书面形式进行的,因此以下是复制的步骤: 创建一个.net核心项目(名为“DotNetCorePlayed”,VS2019) 从package manager控制台运行以下命令: dotnet工具安装-g dotnet aspnet codegenerator 以及: dotnet添加dotnetcoregraphy包Microsoft.VisualStudio.Web.CodeGeneration.Design dotnet添加DotNetCore游乐场包Micr

浏览本教程

我所做的一切都是按照书面形式进行的,因此以下是复制的步骤:

  • 创建一个.net核心项目(名为“DotNetCorePlayed”,VS2019)

  • 从package manager控制台运行以下命令:

    dotnet工具安装-g dotnet aspnet codegenerator

  • 以及:

    dotnet添加dotnetcoregraphy包Microsoft.VisualStudio.Web.CodeGeneration.Design
    dotnet添加DotNetCore游乐场包Microsoft.EntityFrameworkCore.Design
    dotnet添加DotNetCore游乐场包Microsoft.AspNetCore.Identity.EntityFrameworkCore
    dotnet添加DotNetCore游乐场包Microsoft.AspNetCore.Identity.UI
    dotnet添加DotNetCore游戏包Microsoft.EntityFrameworkCore.SqlServer
    dotnet添加DotNetCore游戏包Microsoft.EntityFrameworkCore.Tools

  • 一切都按预期进行,结果是:

      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
      </ItemGroup>
    
    结果是:

    dotnet : Scaffolding failed.
    At line:1 char:1
    + dotnet aspnet-codegenerator identity -h p C:\Users\[user]\sou ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (Scaffolding failed.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
    
    Could not find project file in C:\Users\[user]\source\repos\DotnetCoreplayGround
    
    知道为什么找不到项目文件吗?

    我尝试运行:

    dotnet aspnet codegenerator-help
    和got脚手架失败错误。 问题是我的
    .config
    文件夹被删除了(我不知道为什么)

    我是如何解决问题的:

    我在其中创建了一个新的
    .config
    文件夹和一个新的
    dotnettools.json
    文件

    文件内容:

    {
      "version": 1,
      "isRoot": true,
      "tools": {
        "dotnet-ef": {
          "version": "3.1.3",
          "commands": [
            "dotnet-ef"
          ]
        },
        "dotnet-aspnet-codegenerator": {
          "version": "3.1.1",
          "commands": [
            "dotnet-aspnet-codegenerator"
          ]
        }
      }
    }
    
    然后转到终端并运行dotnet工具还原


    就这样

    你找到解决办法了吗?嘿,AnatolyNikolaev,恐怕没有
    {
      "version": 1,
      "isRoot": true,
      "tools": {
        "dotnet-ef": {
          "version": "3.1.3",
          "commands": [
            "dotnet-ef"
          ]
        },
        "dotnet-aspnet-codegenerator": {
          "version": "3.1.1",
          "commands": [
            "dotnet-aspnet-codegenerator"
          ]
        }
      }
    }