Invalid object name dbo.Categories

2019-06-08 02:44发布

问题:

I am working on MVC 3. I am trying to create Simliar application as MVC Music Store but I am getting an error. My code is below:

 using EFCodeFirst
 BookDBContext _db = new BookDBContext();
 [ChildActionOnly]
 public ActionResult GenreMenu()
 {
    var categories = _db.Category.ToList();//**Giving error at this pointInvalid object name dbo.Categories**
        return PartialView(categories);
 }

回答1:

Verify that your BookDBContext contains a property called Category and that your database contains table dbo.Categories.