Home > ASP.NET, MVC > ASP.NET MVC 1.0 – Model Item error

ASP.NET MVC 1.0 – Model Item error

Just to get the hang of it, today I started to learn what really ASP.NET MVC is. I have Visual Studio 2008 and Framework 3.5 SP1. I installed ASP.NET MVC 1.0 from the asp.net site. I learnt that Entity Framework comes with SP1. I also wanted to explore the entity framework.
I tried this tutorial.

Also I didn’t get this _db.MovieSet.ToList().Somehow my intellisense didn’t pick up this MovieSet. I was unable to compile. After that I changed the code to _db.MovieMaster.ToList() where _db represents my entity and MovieMaster is my table. The application compiled well But when I run the application and browsed to my URL, aha, I got the following error.

The model item passed in to the dictionary is of type ‘System.Collections.Generic.List’1…but this dictionary requires a model item of type..


I searched through Google and I found a guy who has exactly asked the same question. But he didn’t get the answer for that. I even tried the free book http://weblogs.asp.net/scottgu/archive/2009/03/10/free-asp-net-mvc-ebook-tutorial.aspx which I found in ScottGu’s blog. Really that book appeared complex to me.

After going through the searches and getting little frustrated, that thought struck me. The error appears to be like there are some handshake problem with Controller and View. Controller gives a collection object while view expects a Model item.

At first, I created the view from the Controller class when I was in the middle of the code.

public ActionResult Index()

return View();

I right clicked Index in controller and generated the View. As you see, View is just empty. The View Content dropdown in Add View pop-up was disabled. So when I created the View, I didn’t have the HTML to show the list or anything. The View was empty.

I changed my code to this:

public ActionResult Index()

return View(_db.MovieMaster.ToList());

I deleted the existing View for Index and recreated the view.


Now my View content drop down is enabled and I selected List from the dropdown. My newly created View had the entire HTML to show the List and everything worked fine!

Categories: ASP.NET, MVC
  1. Piotr
    December 4, 2009 at 11:24 am

    Thanks, mate! You have just saved me 😉

    • January 21, 2010 at 6:15 am

      Piotron, Glad the tip was of some help!

  2. MacGyver
    March 20, 2012 at 9:24 pm

    Thank you so much! You’ve just helped me a lot with this solution!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: