ASP.NET MVC(5) How to add Partials with Model Data. (Just to help others I struggled with this

I have looked all over for this answer and with alot of different examples i was unable to complete this until i did a lot of trial and error. I was getting a null value. Object reference not set to an instance of an object. To help others here is how i did it.

Model class

public class Blogs
    public int Id { get; set; }
    public string UserName { get; set; } 
    public string Post { get; set; }
}  // gets and set the db data


public ActionResult _BlogPartial()
    return PartialView(db.Blogs.ToList());

This set the partial view data to instance of object



Razor syntax with htmlhelper. The Action routes to the associated controller and looks for the ActionResult you specified.

Hope this helps I spend hours on it, kind of new to ASP.NET MVC