简体   繁体   English

DbContext 没有编译?

[英]DbContext not compiling?

i am following a step by step to learn mvc and creating a music shop but for some reason i cant get the following code to work..我正在逐步学习 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; }
    }
}

The DBcontext, DbSet and DbSet are giving errors... DBcontext、DbSet 和 DbSet 给出错误...

Error 1 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)错误 1 找不到类型或命名空间名称“DbContext”(您是否缺少 using 指令或程序集引用?)

why?为什么?

You must add a reference to the EntityFramework.dll assembly to your project.您必须在项目中添加对EntityFramework.dll程序集的引用。 The simplest way to do this is installing the corresponding NuGet package .最简单的方法是安装相应的NuGet package If you have installed the ASP.NET MVC 3 Tools Update this NuGet package is referenced by default when you create a new project.如果您已安装ASP.NET MVC 3 工具更新此 NuGet package 在您创建新项目时默认引用。 If not, simply install it.如果没有,只需安装它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM