I am trying to pass valued from my database to a shared view but I keep getting this error (Please note I am very new to MVC, so I dont understand the error I get) -
The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[civtbg.Models.tbl_Player_Details]', but this dictionary requires a model item of type 'civtbg.Models.civtbgdbEntities'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[civtbg.Models.tbl_Player_Details]', but this dictionary requires a model item of type 'civtbg.Models.civtbgdbEntities'.
As mentioned I am knew to this, so not sure if there is a place where I can read into this or there might be an "easy" solution for this ?
Thanks for all your help
What I have tried:
I have tried these on the controllers index (so I commented after they gave me the same error as before) -
public ActionResult Index()
{
civtbgdbEntities db = new civtbgdbEntities();
List<tbl_Player_Details> model = db.tbl_Player_Details.ToList();
return View(model);
}
I passed the PlayerDetails when I tested those in the View
In my partial view, I tried these
model List<civtbg.Models.tbl_Player_Details>
In my Shared view I used one of these at the top at a time -
@model List<civtbg.Models.tbl_Player_Details>
@model IEnumerable<civtbg.Models.tbl_Player_Details>
@model civtbg.Models.tbl_Player_Details
In the layout I use this -
@Html.Action("Testing", "Home")
, where Testing is calling the my Shared View
In my Shared View I am not trying to display data from the database, only added one of the @model at the top