I have two classes, the first one is base class and second one is inherited from first.
public class hgm
{
}
public class Laboratory : hgm
{
}
I used EF Code First to generate the database. Also, I used the default Scaffold to generate controllers and views.
I can use edit, create, details pages but for index(the list of instances), there is an error:
The model item passed into the dictionary is of type
'System.Collections.Generic.List'1[armnab.Models.hgm]'
, but this dictionary requires a model item of type'System.Collections.Generic.IEnumerable'1[armnab.Models.Laboratory]'
Here is my controller:
public class LaboratoriesController : Controller
{
private hgmContext db = new hgmContext();
// GET: Laboratories
public ActionResult Index()
{
return View(db.hgms.ToList());
}
}
and the view:
@model IEnumerable<armnab.Models.Laboratory>
<h2>Index</h2>
Why is this error occuring?