I have two classes called Company and Address.
I have created a ViewModel for both.
But when I go to the controller and right click to add controller, enter Controller name, Model class as newViewModel and Data context class as dbModel.
It gives me error and is not creating a controller and view for CRUD.
What am I doing wrong?
public class nameViewModel
{
public Company Company { get; set; }
public Address Address { get; set; }
}
Company Table:
CompanyId
Name
Address
Value
Address Table:
AddressId
Address
enter code here
With the questions you are asking, it seems pretty clear that you should start at the beginning and work through a tutorial. I haven’t worked through a tutorial since the NerdDinner tutorial for MVC2, but this tutorial seems like a pretty good place to start: Getting started with ASPNet MVC3. And in answer to your question about returning “two controllers in one view”, a controller (or an action on a controller) is just code that runs in response to a web request. In that action, you would create an instance of your ViewModel (nameViewModel) and return it to a view that expects that viewmodel.