I have a C# MVC project with a database first approach. I also have to tables Products and Company. The product has a foreign key to the company table. I want to be able to load the product as a model yet be able to show the company code and logo with the product information.
I have looked at a lot of different articles etc but it doesn't seem to answer my question.
I'm not new to C# ASP.NET but am new to the MVC side.
MVC need to link 2 tables into one model?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Bhavik PatelRank #991 · 2K reputationPosted Jan 21, 2015, 9:55 PM EST
ProductCompanyModel
{
public string ProductName{get;set;}
public string ProductCategory{get;set;}
public string CompanyName{get;set;}
public string logo{get;set;}
}
if you are showing list of data then
@foreach(var item in ViewBag.Data as List
{
// show your data
}
if you are showing data as single page take ProductCompanyModel as @model
Hope you will get your solution
Thanks and Regards,
Bhavik Patel
Jonathan Meyer5 reputationPosted Jan 21, 2015, 10:04 PM EST
From the model created by EF I already have a List (even though its a 1 to many from the product side) ...Just for information purposes.
I'm going to create the VM in the BLL and the actual models are in my DAL library