ASP.NET Product Listing
I would definitely remove the database access from the Category partial view and move it to the Controller (you can add it to the view model or have a separate action for returning them which is even more clean).

Views are supposed to be dumb layouts and not perform any business logic. Removing the database context shouldn't affect the compilation of the views.

Small refactoring suggestion for the Controller:

    public ActionResult Category(int? id)
    {
        var pid = id ?? 1;  //if requested id is null, set is as 1

        var category = db.Categories.Find(pid);

        if (category == null)  //if category does not exist, return Error
            return View("Error");

        var model = category.Products.ToList(); //return list of projects in requested category

        return View(model);
    }


Don't call find twice will save an extra database access which is important and code style wise I would use the ?? operator as you see above.

What the View("Error") is doing? Do you have an error view or is it just raising an exception? In both cases I would be more specific.

I would also make the view strongly typed as it will prevent errors and give you IntelliSense.