I have been converting a site from MVC2 to MVC3 and while I have managed to get it working I am plagued by the error message
"The model item passed into the dictionary is of type 'System.Data.Linq.SqlClient.SqlProvider+SingleResult`1[NutritionLabel3.Models.sp_get_ingredientNutritionFoomasResult]', but this dictionary requires a model item of type 'NutritionLabel3.Models.sp_get_ingredientNutritionFoomasResult'. "
This error comes from the Model layer that implements a Linq2Sql data layer. This code works fine in MVC2. I have conducted a number of tests by building new MVC3 sites with a new Linq2Sql interface to verify that this is repeatable. A typical implementation of a Linq2Sql call in the controller would look like this:
public ActionResult Index()
{
NutritionLabel3.Models.testDataContext dbContext = new Models.testDataContext();
var nutritionData = dbContext.sp_get_ingredientNutritionFoomas(2, 1, 2);
return View(nutritionData);
}
It seems that the implicit type conversion message is very arcane. Has anyone fought this battle yet in MVC3?
Any help would be much appreciated!!
PatC