简体   繁体   English

使用 NuGet Package Manager 安装 Entity Framework 6 不会创建相关引用。 (我认为)

[英]Installing Entity Framework 6 with NuGet Package Manager does not create the relevant references. (I think)

I am following the "Getting Started with Entity Framework 6" tutorial by Julie Lerman on Pluralsight.我正在关注 Pluralsight 上 Julie Lerman 的“Entity Framework 6 入门”教程。

In the 4th video of module 2, she instructs to download the Entity Framework package from the NuGet Package Manager.在模块 2 的第 4 个视频中,她指示从 NuGet Package 管理器下载实体框架 package。 When she does this:当她这样做时:

  1. The relevant reference is added to the project.相关参考被添加到项目中。
  2. An "App.config" file is created.创建一个“App.config”文件。

When I do this none of that happens.当我这样做时,这些都不会发生。

When I try to inherit DbContext (which is what she does next), I get these errors:当我尝试继承 DbContext(这是她接下来要做的)时,我收到以下错误:

CS0246 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) NinjaDomain.DataModel C:\Learn\Ninja.Demo\NinjaDomain.DataModel\Class1.cs 6 Active CS0246 找不到类型或命名空间名称“DbContext”(您是否缺少 using 指令或程序集引用?) NinjaDomain.DataModel C:\Learn\Ninja.Demo\NinjaDomain.DataModel\Class1.cs 6 活动

CS0234 The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) NinjaDomain.DataModel C:\Learn\Ninja.Demo\NinjaDomain.DataModel\Class1.cs 2 Active CS0234 命名空间“System.Data”中不存在类型或命名空间名称“Entity”(您是否缺少程序集引用?) NinjaDomain.DataModel C:\Learn\Ninja.Demo\NinjaDomain.DataModel\Class1.cs 2 活动

The code that generates these errors:产生这些错误的代码:

using System;
using System.Data.Entity;

namespace NinjaDomain.DataModel
{
    public class NinjaContext : DbContext
    {
    }
}

The words "Entity" from the 2nd line and "DbContext" from the 6th line are red-squiggled.第 2 行中的“Entity”和第 6 行中的“DbContext”是红色波浪线。

I am using Visual Studio 2019, while she is using Visual Studio 2015, which I assume to be the problem.我使用的是 Visual Studio 2019,而她使用的是 Visual Studio 2015,我认为这是问题所在。

This is what my solution looks like.这就是我的解决方案的样子。

Help?帮助?

The issue was lack of attention on my part.问题是我缺乏关注。 When creating the project, I chose "Class Library (.NET Standard)" instead of "Class Library (.NET Framework)".创建项目时,我选择了“类库(.NET Standard)”而不是“类库(.NET Framework)”。

暂无
暂无

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

相关问题 当我在 package 管理器控制台中的 Visual Studio 2013 中安装实体框架时 - When I am installing Entity Framework in Visual Studio 2013 in the package manager console nuget 包 Microsoft.Data.SqlClient 是否适用于实体框架? - Does the nuget package Microsoft.Data.SqlClient work with Entity Framework? 缺少对 NuGet 软件包的引用。 Package 恢复或重新安装包不起作用 - References to NuGet packages that are missing. Package Restore or re-installing packages does not work 如何为解决方案中的每个项目创建单独的 nuget 包,并将项目引用转换为 nuget 依赖项? - How do I create an individual nuget package for each project in a solution, with project references converted to nuget dependencies? Nuget 管理器未使用 package 管理器从 Internet 安装软件包 - Nuget manager not installing packages from internet using package manager 为什么 do.net 构建在 .NET Framework 4.5 项目上会抛出“该项目引用了 NuGet 缺少的包”? - Why does dotnet build on a .NET Framework 4.5 project throw "This project references NuGet package(s) that are missing"? 实体框架6 SqlFunctions DateDiff未在nuget包中实现 - Entity Framework 6 SqlFunctions DateDiff not implemented in nuget package 在没有nuget软件包管理器的情况下安装fluentvalidation.webapi? - Installing fluentvalidation.webapi without nuget package manager? 实体框架包管理器控制台问题 - Entity Framework Package Manager Console question 解决nuget包引用 - Resolving nuget package references
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM