Hello am getting this error when im trying to run my code to view data
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[NewKLUE.Models.Tutorial]', but this dictionary requires a model item of type 'NewKLUE.Models.IndexViewModel'.
My controller
- public async Task PHP()
- {
- var tutorials = db.Tutorials.Where(t => t.CoursesName == "PHP");
- return View(await tutorials.ToListAsync());
- }
My model
- [Table("Tutorial")]
- public class Tutorial
- {
- [Key]
- public int TutorialId { get; set; }
-
- [Required(ErrorMessage = "Course Name is required")]
- [Display(Name = "Course Name")]
- public string CoursesName { get; set; }
-
-
- [Display(Name = "Topic")]
- public string Topic { get; set; }
-
- [Required(ErrorMessage = "Tutorial discription is required")]
- public string Description { get; set; }
-
- [AllowHtml]
- public string Content { get; set; }
-
- public DateTime CreatedOn { get; set; }
-
- [ForeignKey("User")]
- public string UserId { get; set; }
-
- public virtual ApplicationUser User { get; set; }
- }
and my View
- @model IEnumerable
- @using NewKLUE.Models
- @{
- ViewBag.Title = "PHP";
- }
-
PHP
-
-
- ="table">
-
-
- @Html.DisplayNameFor(model => model.User.FirstName)
-
-
- @Html.DisplayNameFor(model => model.CoursesName)
-
-
- @Html.DisplayNameFor(model => model.Topic)
-
-
- @Html.DisplayNameFor(model => model.Description)
-
-
- @Html.DisplayNameFor(model => model.Content)
-
-
- @Html.DisplayNameFor(model => model.CreatedOn)
-
-
-
-
- @foreach (var item in Model) {
-
-
- @Html.DisplayFor(modelItem => item.User.FirstName)
-
-
- @Html.DisplayFor(modelItem => item.CoursesName)
-
-
- @Html.DisplayFor(modelItem => item.Topic)
-
-
- @Html.DisplayFor(modelItem => item.Description)
-
-
- @Html.DisplayFor(modelItem => item.Content)
-
-
- @Html.DisplayFor(modelItem => item.CreatedOn)
-
-
- @Html.ActionLink("Details", "Details", new { id=item.TutorialId })
-
-
- }
-
-
Please help I dont understand the error at all
i ll apriciate any help.