|
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! :-)
-glahens
|