Guys, if you are talking about when you try to go to edit or create and you get this error, this should be the solution. I was encountering the same thing and this was a very easy fix. This is a little long, but it really is only a one line fix for each method. So, if the above dilemma was your issue, please continue to read and it might help you. Feel free to email me if you don't understand my wording
I figured it out. It seems as if everyone is trying to create or add elaborate methods to do fix an error that is extremely simple to fix. Remember, you start off using the ViewData inherts in you .aspx filesand returning the same in you return statements. Because of that, I figure that it was an issue with the Inherits attribute on the top of the ASP.NET files. But, if you are getting the error when trying to create or edit a new Dinner when you are on the 'Upcoming Dinners' page (generated from the Details.aspx and the LINQ file that gets all Dinners that are after todays date), go into your 'Controllers' directory, specifically the DinnerController.cs. Then look at the Edit and or Create methods. the answer lies right here. If you put breakpoints on these methods, you should be able to figure it out. If not, continue reading:
Look where it fails, the 'return...' line. Maybe I am the only person who forgot to change this, but my error is the same as people are getting in this page and this os how I fixed it.....the 'return(dinner)' line, in Create and Edit (and any others that you are having issues with), they are using the NerDinner.Model.Dinner / ViewData method. However, if you change it to the ViewModel return method instead, it should fix it, For example: 'return(new DinnerFormViewModel(dinner));', it should work for you. I hope this helps, as it was what my issue was. Just a simple overlook.
P.S. - I am not trying to insult anyone createing these extra methods. Maybe they are doing them for a reason. But if it is for an error that requires a logical fix, creating all of these new methods confuses the f@#$ out of me because I think that I should have done it that way and now I have to learn something new. So please, don't take any offense. It is just when you are trying to learn something new and you run into an error, and a hack is to write something new, it just turn my brain into marshmellow and I have to quit. But, of course your help is greatly appreciated:
-wrikgee
When angry, count ten; when very angry, a hundred - Thomas Jefferson