C# 类型或命名空间名称';EntityFrameworkCore';命名空间中不存在';微软

C# 类型或命名空间名称';EntityFrameworkCore';命名空间中不存在';微软,c#,razor,asp.net-core,visual-studio-2017,C#,Razor,Asp.net Core,Visual Studio 2017,我尝试为VisualStudio2017做Razor ContosUniversity(在ContsoObserve initally中重命名),结果发现错误 我的csproj是 <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netcoreapp2.0</TargetFramework> </PropertyGroup>

我尝试为VisualStudio2017做Razor ContosUniversity(在ContsoObserve initally中重命名),结果发现错误 我的csproj是

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.1" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Update="Microsoft.NETCore.App" Version="2.0.4" />
  </ItemGroup>
  <ItemGroup>
        <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
    </ItemGroup>
</Project>
得到

生成失败。 Data\SchoolContext.cs(5,17):错误CS0234:命名空间“Microsoft”中不存在类型或命名空间名称“EntityFrameworkCore”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\About.cshtml.cs(5,32):错误CS0234:命名空间“Microsoft.AspNetCore.Mvc”中不存在类型或命名空间名称“RazorPages”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Contact.cshtml.cs(5,32):错误CS0234:命名空间“Microsoft.AspNetCore.Mvc”中不存在类型或命名空间名称“RazorPages”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Error.cshtml.cs(6,32):错误CS0234:命名空间“Microsoft.AspNetCore.Mvc”中不存在类型或命名空间名称“RazorPages”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Index.cshtml.cs(6,32):错误CS0234:命名空间“Microsoft.AspNetCore.Mvc”中不存在类型或命名空间名称“RazorPages”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(7,28):错误CS0234:命名空间“Microsoft.AspNetCore”中不存在类型或命名空间名称“Hosting”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(8,28):错误CS0234:命名空间“Microsoft.Extensions”中不存在类型或命名空间名称“Configuration”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(9,28):错误CS0234:命名空间“Microsoft.Extensions”中不存在类型或命名空间名称“Logging”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(5,28):错误CS0234:命名空间“Microsoft.AspNetCore”中不存在类型或命名空间名称“Builder”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(6,28):错误CS0234:命名空间“Microsoft.AspNetCore”中不存在类型或命名空间名称“Hosting”(是否缺少程序集引用?[C:\Users\STR\source\repos\contosobserve\contosobserve\contosobserve.csproj] Startup.cs(7,28):错误CS0234:命名空间“Microsoft.Extensions”中不存在类型或命名空间名称“Configuration”(是否缺少程序集引用?[C:\Users\STR\source\repos\contosobserve\contosobserve\contosobserve.csproj] Startup.cs(10,17):错误CS0234:命名空间“Microsoft”中不存在类型或命名空间名称“EntityFrameworkCore”(是否缺少程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\About.cshtml.cs(9,31):错误CS0246:找不到类型或命名空间名称“PageModel”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(39,23):错误CS0246:找不到类型或命名空间名称“IWebHost”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(10,34):错误CS0246:找不到类型或命名空间名称“DbContext”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(21,16):错误CS0246:找不到类型或命名空间名称“IConfiguration”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Contact.cshtml.cs(9,33):错误CS0246:找不到类型或命名空间名称“PageModel”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve.csproj] Startup.cs(33,31):错误CS0246:找不到类型或命名空间名称“IAApplicationBuilder”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(33,56):错误CS0246:找不到类型或命名空间名称“IHostingEnvironment”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(16,16):错误CS0246:找不到类型或命名空间名称“DbSet”(您是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve.csproj] Startup.cs(16,24):错误CS0246:找不到类型或命名空间名称“IConfiguration”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Error.cshtml.cs(10,31):错误CS0246:找不到类型或命名空间名称“PageModel”(是否缺少using指令或程序集引用?[C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(17,16):错误CS0246:找不到类型或命名空间名称“DbSet”(是否缺少using指令或asse
dotnet aspnet-codegenerator razorpage -m Student -dc SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries