Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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..

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...

Error 1 The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)

why?

like image 645
Beginner Avatar asked Jul 14 '11 09:07

Beginner


1 Answers

You must add a reference to the EntityFramework.dll assembly to your project. The simplest way to do this is installing the corresponding 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. If not, simply install it.

like image 113
Darin Dimitrov Avatar answered Oct 06 '22 06:10

Darin Dimitrov