I want to get data from two tables with single Entity class. How??
public class HomeViewModel
{
[Key]
[Column(\"candidate_ID\")]
public int cand
This is called entity splitting. To make it work your CandidateID
must be primary key in both tables and foreign key in the second table (entity splitting works only with one-to-one relations in a database).
Edit: There is another limitation. Entity splitting doesn't allow optional relations. Records in both tables must exists to make this work so if your table2 records are optional you must map both tables separately and construct your view model in the application from loaded records.