我是一步一步地学习mvc和创建一个音乐商店,但由于某种原因,我无法得到以下代码的工作。
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; }
}
}DBcontext,DbSet和DbSet都犯了错误.
错误1无法找到类型或命名空间名称'DbContext‘(您是缺少使用指令还是程序集引用?)
为什么?
发布于 2011-07-14 09:46:10
必须将对EntityFramework.dll程序集的引用添加到项目中。最简单的方法是安装相应的NuGet package。如果已安装了ASP.NET MVC 3 Tools Update,则在创建新项目时默认引用此NuGet包。如果没有,只需安装它。
https://stackoverflow.com/questions/6691240
复制相似问题