[英]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:
当她这样做时:
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.