Why doesn’t my viewModel get inherited? I have the following viewModels:
public class BaseViewModel {
public BaseViewModel() {
Location = new Location { };
}
public Location Location { get; set; }
}
public class EditViewModel : BaseViewModel {
public Book Book { get; set; }
}
In my controller:
var viewModel = new EditViewModel
{
Book = new Book { Test = "ABC" },
Location = { City = "AAA" }
};
When I check to see what the viewModel looks like then I find it doesn’t contain the location class even though my view inherits from the BaseViewModel. Can anyone see why this is. How can I ensure the view contains Location?
Weird, because the following compiles and works just fine for me:
and in the view: