Search code examples
asp.net-mvcdatabaseasp.net-mvc-3store

mvcmusicstore v3.0 (storeDB does not exist in the current context)


It's my first dealing with mvc and I am going with a tutorial from this link https://archive.codeplex.com/?p=mvcmusicstore . I have all steps done but when I write:

public ActionResult Index()    
{
    var genres = storeDB.Genres.ToList();
    return View(genres);
}

it says storeDB does not exist in the current context. Why am I getting this message?
Please help in that


Solution

  • In your context you have DBSet<Genre> Genre (not plural)

    Within you controller you have - (Genres plural)

    var genres = storeDB.Genres.ToList();
    

    So you could change to -

    var genres = storeDB.Genre.ToList();