Very new to ASP.net Core 2 MVC but trying to figure things out.
I have created a ViewModel:
ublic class PeopleStateViewModel { public People People { get; set; } public StatesDictionary States { get; set; } public PeopleStateViewModel(People people) { People = people; States = new StatesDictionary(); } }
I Have these two models:
public class People { public int ID { get; set; } [StringLength(60, MinimumLength = 2)] [Required] public string FirstName { get; set; } [StringLength(60, MinimumLength = 2)] [Required] public string LastName { get; set; } } public static SelectList StateSelectList { get { return new SelectList(StateDictionary, "Value", "Key"); } } public static readonly IDictionary<string, string> StateDictionary = new Dictionary<string, string> { {"Choose...",""} , { "Alabama", "AL" } , { "Alaska", "AK" } , { "Arizona", "AZ" } , { "Arkansas", "AR" } , { "California", "CA" } // code continues to add states... }; }
I try to create a controller using MVC Controller with views, using Entity Framework.
I then get this error:
I want to be able to use data from both classes on a view...
Any help is appreciated.