Yes, you will find it in awesome book Pro ASP.NET MVC 4
on page 101 (razor) and 183 (paging). It is the must read book!
Pro ASP.NET MVC 4 (Professional Apress)
this series is great.
My guess is you should try to place the code below under protected void Application_Start() in the Global.asax.cs. This way, you database connection will always be Initialized before everything else.
protected void Application_Start()
"UserProfile", "UserId", "UserName", autoCreateTables: true);
Maybe this Pro Asp.Net Mvc 4 will help you set up your testing project. There is also an MVC 3 version, but they will pretty much say the same thing. They suggest to use Moq Library, and its helped me in the past.