Beginner
Beginner

Reputation: 29533

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?

Upvotes: 5

Views: 6885

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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.

Upvotes: 5

Related Questions