C# DbContext没有编译吗?
我正在一步一步地学习mvc并创建一个音乐商店,但由于某些原因,我无法使用以下代码C# DbContext没有编译吗?,c#,.net,entity-framework,compiler-errors,C#,.net,Entity Framework,Compiler Errors,我正在一步一步地学习mvc并创建一个音乐商店,但由于某些原因,我无法使用以下代码 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Entity; namespace MvcMusicStore.Models { public class MusicStoreEntities : DbContext { pu
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace MvcMusicStore.Models
{
public class MusicStoreEntities : DbContext
{
public DbSet<Album> Albums { get; set; }
public DbSet<Genre> Genres { get; set; }
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Data.Entity;
命名空间MvcMusicStore.Models
{
公共类MusicStoreEntities:DbContext
{
公共数据库集相册{get;set;}
公共数据库集类型{get;set;}
}
}
DBcontext、DbSet和DbSet正在给出错误
错误1找不到类型或命名空间名称“DbContext”(是否缺少using指令或程序集引用?)
为什么?您必须在项目中添加对
EntityFramework.dll
程序集的引用。最简单的方法是安装相应的。如果已安装,则在创建新项目时,默认情况下会引用此NuGet包。如果没有,只需安装它