Why isn't DbContext compiling?

.net c# compiler-errors entity-framework

Question

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?

1
5
2/25/2013 9:03:21 PM

Accepted Answer

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.

5
7/14/2011 9:46:10 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow