In MVC 4 this mostly happens when you create a MVC 4 project and then for your DAL (Data access layer ) you have a separate class library project and install EF through NuGet. NuGet will give you the latest version which is currently EF 6. When you try to run the project you will see an error similar to the above with a yellow screen of death. The root cause is that MVC 4 has EF5 referenced. So just open up NuGet and upgrade EF to version 6 under updates section and you are good to go.
Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts
Tuesday, February 4, 2014
Saturday, February 1, 2014
ViewBag vs ViewData in ASP.NET MVC
Bottom line is that they are essentially the same, ViewBag is just a dynamic wrapper around ViewData. ViewData is actually a dictionary used to pass data from controllers to views. The following example will make this clear,
ViewBag.Name = "Padmika"
is equal to,
ViewData["Name"] = "Padmika"
ViewBag.Name = "Padmika"
is equal to,
ViewData["Name"] = "Padmika"