I am working through the Mvc Music Store tutorial and am stuck on this LINQ query as it keeps telling me that the sequence has no elements. My model matches the model in the tutorial and I have inserted data into it. I have modified it so instead of albums it is designs.
var genreModel = storeDB.DesignTypes.Include("Designs")
.Single(g => g.Name == designType); -> no elements in sequence
var viewModel = new StoreBrowseViewModel() {
Genre = genreModel,
Albums = genreModel.Designs.ToList()
};
return View(viewModel);
use FirstOrDefault instead of Single:
From msdn:
You have more than one match item or no item.