The idea of a good programming is that a View should not know anything about where the data comes from ... using the Database model in the View breaks that sign.
The best is always use a ViewModel
, and in the future you will be pleased about this choice as for example, a View might be only a 1:1 from a database table, but imagine that the designer wants you also to add the most recent "messages", that's just a new table call based on the user...
With a ViewModel
you can easily add it and just edit your view and controller, but if you use 1:1 you will need to create a brand new ViewModel... then, some Views have ViewModels and some don't... it will be messy!
To help you out, you can always use AutoMapper
to help with the ViewModels construction, AutoMapper automagically populates the destination class with the data from the original class.
var userViewModel = AutoMapper.Mapper.Map<UserViewModel>(user);
Keep in mind to separate concerns, a Controller
should not know where the data comes from (hence, using Repositories
) and a View should not do data manipulation (hence the Controller
).