I'm using ASP.NET MVC5 to create an app. My view model class is complex, as it has some attributes that are lists of objects. I tried to create a 'create' view for the following model using MVC scaffolding, but it just kind of ignored the object list attributes of my view model... See my view model below... scaffolding only created html elements for Name, ImagePath etc.. not for BandGenres.
Is there a way to use MVC5 scaffolding to also create view elements for the lists of objects in my view model?
public class BandRegisterVM
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string ImagePath { get; set; }
public string Description { get; set; }
public BandGenresVM Genres { get; set; } //is a list see below
public BandLinksVM Links { get; set; }
}
public class BandGenresVM
{
public IEnumerable<BandGenreVM> BandGenres { get; set; }
}
public class BandLinksVM
{
public IEnumerable<BandLinkVM> BandLinks { get; set; }
}
public class BandGenreVM
{
[Key]
public int Id { get; set; }
public int BandId { get; set; }
public string Name { get; set; }
public int GenreId { get; set; }
public string Genre { get; set; }
}
public class BandLinkVM
{
[Key]
public int Id { get; set; }
public int BandId { get; set; }
public string Name { get; set; }
[Url]
public string URL { get; set; }
}