A word of Advice. Don't get EF 4.1 via NuGet

May 17, 2011 at 8:20 AM

Using Visual Studio 2010 & MVC 3/Razor. Download EF 4.1 first from Microsoft and install that before using "Install-Package" to grab MVCScaffolding. It'll save you a lot of heartache!!!

It took me a long while to figure this out because I kept having strange issues with MVCScaffolding before I figured out that much of the problem was with Entity Framework 4.1. When you grab MVCScaffolding via the recommended NuGet method EF 4.1 is also downloaded but it is not the full install of this library and some important pieces end up missing in Visual Studio 2010.  Those missing pieces are the new data object templates (DbContext, EntityObject, etc) You can tell that these are missing by opening an entity designer (the edmx file) and right clicking on the background surface and selecting the menu option to "Add Code Generation Item..." Then in the resulting box that comes up select from the "Installed Templates" treeview on the left side under "C#" the item called "Code". In the main portion of the window if you don't see "EntityObject" and/or "DbContext" then it's likely that you installed EF 4.1 via NuGet and not from the official MS full install package. The full package is easily found on the http://Asp.net/ site.

This wasted several hours for me. Especially confusing when the classes I keep generating with MVCScaffolding won't compile. Also found it very difficult without that to generate an Entity Model from a SQL database and then Scaffold views and controllers from that model. Once again, without the DBContext templates installed and activated against the Entity Model, the generated classes would NOT compile.

This is likely missed by the MVCScaffolding devs b/c they already have the pre-requisite tools installed on their machine. But the issue certainly lies with the EF 4.1 package on NuGet. That package needs fixing it seems.

I hope this helps someone else out there. Once I got past this problem the tool worked great!  :-)



May 29, 2011 at 8:11 PM

This was extremely helpful... I couldn't quite figure out how to automatically build a DataContext from an existing EF Model.

- Danny g


Sep 13, 2011 at 1:18 PM

Thank you!

Oct 31, 2011 at 6:25 AM

Thank you also!

Dec 20, 2011 at 9:39 AM

Thank you - that problem was driving me nuts

lets hope it gets fixed in the next version of nuget

Feb 10, 2012 at 12:21 PM
Microsoft Visual Studio
Unable to retrieve metadata for '...'. The type '...' was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.
Just upgraded EF cf 4.2 to EF cf 4.3 via NuGet :(