....................Please be patient its a story..........
I am using code first approach in my mvc project. i want to know what is more practical approch for my condition
i have a candidate table which is connected with four or five more tables Via Can Id (One to many Relation)
Candidate class(code first class) has fields related to connected tables e.g
public int SelectedEdu {get;set;}
public IEnumerable<education> Edu {get;set;}
more classes are there i am showing only one.
using entityframwork i am fetching education related to that candidate via Can Id (this shows no join and no viewModel usage)
Edu is obviously a list which i am showing on a View related to that candidtae,. by any way (i am not going to show HOW hope that clears,as my code working well).
On the other hand if i wish to use ViewModels i have to join education table with candidate table w.r.t. Can ID(again i am not showing code.assume a linq query to join as i am in the developers world, every single reader is aware of that)
anyway by getting record in a viewmodel i am just facing an issue that for the first time if candidate go to his/her profile there would be no matching candidate Id in Education table as it is the first time user login OR by any other reason eduction table is empty regarding that candidate so NO join is possible here also.
what i did to handle this thing is at the time of sign up i generated CanId in education table after record enter to candidate table.By doing this education table got CanId With all other null values(Here Linq join query comes into picture and works)
and everything is working fine in both the conditions
i want to know which approach is more practical to use ViewModels or Code First Model Classes in industry