gpt4 book ai didi

c# - EF CodeFirst 引用 DbContext 类

转载 作者:行者123 更新时间:2023-12-02 05:38:14 24 4
gpt4 key购买 nike

我在 Visual Studio 中创建了一个空的 C# 项目,并添加了一个类。然后我添加了对 System.Data.Entity dll 的引用。我在我的项目中添加了一个类,并继续为我编写一个 DbContext 对象,如下所示。但是,我收到以下错误消息。我还需要引用哪些其他 dll 才能使用它?

Error 1 The type or namespace name 'DbContext' does not exist in the namespace 'System.Data.Entity' (are you missing an assembly reference?)

using System; 
using System.Linq;
using System.Threading.Tasks;
using System.Data.Entity;

namespace Budget.Data
{
public class BudgetContext : System.Data.Entity.DbContext
{

}
}

最佳答案

DbContext 存在于较新版本的EntityFramework 中,因此您需要下载较新版本(或使用nu-get 获取)。该 dll 称为 EntityFramework.dll

关于c# - EF CodeFirst 引用 DbContext 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11380167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com