简体   繁体   English

命名空间“Microsoft”中不存在“EntityFrameworkCore”

[英]'EntityFrameworkCore' does not exist in the namespace 'Microsoft'

I follow this tutorial: https://docs.microsoft.com/en-us/ef/core/get-started/full-dotnet/new-db step by step我遵循本教程: https ://docs.microsoft.com/en-us/ef/core/get-started/full-dotnet/new-db 一步一步

but I cannot add the "Microsoft.EntityFrameworkCore " namespace to Model.cs但我无法将“Microsoft.EntityFrameworkCore”命名空间添加到 Model.cs

I use Visual studio 2017我使用 Visual Studio 2017

and install Microsoft.EntityFrameworkCore.SqlServer(1.1.2) ,并安装 Microsoft.EntityFrameworkCore.SqlServer(1.1.2) ,

Microsoft.EntityFrameworkCore.Tools (1.1.1) , Microsoft.EntityFrameworkCore.Tools (1.1.1) ,

and .NET Framework 4.5.2和 .NET Framework 4.5.2

Visual Studio says: Visual Studio 说:

The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)命名空间“Microsoft”中不存在类型或命名空间名称“EntityFrameworkCore”(您是否缺少程序集引用?)

They added to .csproj :他们添加到 .csproj :

在此处输入图像描述

Copying the following code into the TodoApi.csproj from https://github.com/aspnet/Docs/tree/master/aspnetcore/tutorials/first-web-api/sample/TodoApi worked for me on a similar issue.将以下代码从https://github.com/aspnet/Docs/tree/master/aspnetcore/tutorials/first-web-api/sample/TodoApi复制到 TodoApi.csproj 中对我来说类似的问题。

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>

</Project>

Microsoft.AspNetCore.All may be excessive but it includes EntityFrameworkCore etc Microsoft.AspNetCore.All 可能过多,但它包括 EntityFrameworkCore 等

C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(90,5): Error: The Microsoft.AspNetCore.All package is not supported when targeting .NET Core 3.0 or higher. C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(90,5):错误:Microsoft.AspNetCore.All 包面向 .NET Core 3.0 或更高版本时不支持。 A FrameworkReference to Microsoft.AspNetCore.App should be used instead, and will be implicitly included by Microsoft.NET.Sdk.Web.应改为使用对 Microsoft.AspNetCore.App 的 FrameworkReference,并将隐式包含在 Microsoft.NET.Sdk.Web 中。

For anyone at 3.0 or higher with same error对于 3.0 或更高版本的任何人都有相同的错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EntityFrameworkCore 在命名空间 Microsoft 中不存在 - EntityFrameworkCore does not exist in the namespace Microsoft 命名空间“Microsoft.EntityFrameworkCore”中不存在“迁移” - 'Migrations' does not exist in the namespace 'Microsoft.EntityFrameworkCore' 命名空间“Microsoft”中不存在类型或命名空间名称“EntityFrameworkCore” - The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft Microsoft名称空间中不存在ApplicationInsight - ApplicationInsight does not exist in the namespace Microsoft 命名空间“SharePoint”在命名空间“Microsoft”中不存在 - Namespace 'SharePoint' does not exist in the namespace 'Microsoft' Microsoft.Reporting 在命名空间中不存在 - Microsoft.Reporting does not exist in namespace 命名空间“Microsoft.VisualBasic”中不存在类型或命名空间名称“FileIO” - The type or namespace name 'FileIO' does not exist in the namespace 'Microsoft.VisualBasic' 类型或名称空间名称“ DirectX”在名称空间“ Microsoft” Windows 8.1中不存在 - The type or namespace name 'DirectX' does not exist in the namespace 'Microsoft' Windows 8.1 命名空间“Microsoft”中不存在类型或命名空间名称“设备” - The type or namespace name 'Devices' does not exist in the namespace 'Microsoft' 类型或名称空间CodeAnalysis在名称空间&#39;Microsoft.SqlServer.Dac中不存在 - The type or namespace CodeAnalysis does not exist in the namespace 'Microsoft.SqlServer.Dac
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM