Lesson 4 MvcMusicStorre - Just dropping SampleData.cs into project gives following compile error

Jun 10, 2012 at 5:44 PM

Just dropping SampleData.cs into project gives following compile error
Error 1 The type 'MvcMusicStore.Models.MusicStoreEntities' cannot be used as type parameter 'TContext' in the generic type or method 'System.Data.Entity.DropCreateDatabaseIfModelChanges<TContext>'. There is no implicit reference conversion from 'MvcMusicStore.Models.MusicStoreEntities' to 'System.Data.Entity.DbContext'.

Coordinator
Jun 12, 2012 at 8:12 AM

The SampleData.cs database initializer depends on the entity classes being defined exactly as listed in the tutorial. Can you verify that your MusicStoreEntities class looks like this? Note that some of these entities are added later in the tutorial - the important part is that the entities class is named correctly, implements DbContext, and has the DbSet properties as shown below:

using System.Data.Entity;

namespace MvcMusicStore.Models {
    public class MusicStoreEntities : DbContext {
        public DbSet<Album> Albums { get; set; }
        public DbSet<Genre> Genres { get; set; }
        public DbSet<Artist> Artists { get; set; }
        public DbSet<Cart> Carts { get; set; }
        public DbSet<Order> Orders { get; set; }
        public DbSet<OrderDetail> OrderDetails { get; set; }

    }
}