|Start by installing MVC4 Beta Version (not Release Candidate) from the website http://www.asp.net/mvc/mvc4, then fire up VS2010 (or VS2011) and create a new C# Web MVC4 project, choosing the Internet Application template.|
Once that is ready, then open up the NuGet command line (Tools - Library Package Manager - Package Manager Console), and type in the following commands:
|To activate the FoodTruck, right-click on the project root folder or Controller folder, select the Add menu and the Run Recipe option, and then select the FoodTruck from the resulting popup.|
|The FoodTruck is based on having an existing SQL Server database and table that you are interested in. Enter your login information on the opening screen and click on the Connect button.|
|You should see a list of tables that are in your database. If you don't, then go back to the Credentials tab and try again. Select a table from the list, then click on the button at the bottom of the screen.|
The Edit Fields Screen will show you a list of the fields that are in the table you selected on the previous screen.
You can change the "Pretty Name" of the table to be whatever you want - that will be used as the title on the pages you generate.
You can change the labels for each of the fields by editing the Label column.
You can pick which fields you want to show up on the List and Edit fields by selecting the approriate checkboxes.
You can also modify the field type by selecting the row you want to change, then clicking on the Edit Format button. That will give you a popup that will allow you to choose one of several different formats.
The final screen is the Generate Options screen. The File Location should be pre-populated with the folder name of the project you launched the recipe from. You can change this if you want to generate your files off into a temp directory.
The NameSpace field will be inserted into your project files and was pulled from the project.
The Entity Definition file is where the DbContext records are stored which tell your application what objects your program is interested in. If it doesn't exist, the FoodTruck will generate it for you. It will also add a corresponding entry in the web.config file if it doesn't exist.
If you enter an Editor Security Role, then Authorize tags will be added to each of the Edit functions.
Pick which types of files that you want to generate, then click on the Generate Some Code button. You may be prompted with several choices based on the state of your project.
|The first time you run the program you will get a prompt asking you if it is OK to generate and save some statistics. The program will always store those locally, but if you agree, the number of programs and lines you generate will get posted to the FoodTruck website. This will help us to know how many times this program is used and how many files have been generated. Your cooperation is appreciated!|
On this sample brand new project, the FoodTruck created 53 files and added them to the project. At this point, the project should compile and run, and should be fully functional for both desktop and mobile versions.
The pages have not been added to any menus, so you will have to navigate to them yourself and decide where to put them in the menu.
The List page will limit itself to the first 1000 rows of the table. If you have a larger table, you will have to update the code yourself to decide how to handle that. Once DevExpress supports MVC4, the option to generate a Grid page will be available.
|Sample List Screen|
|Sample Details Screen|
|Sample Mobile List Screen|