This project is read-only.

Adding to the model

This project uses the MVC scaffolding goodness so you can quickly mock up new pages for objects.
  1. Right click Web/Models folder, choose Add Class - e.g. Artist.cs
  2. Add ID and Name, Age etc properties to your class
  3. Open the Package Manager console (View -> Other Windows -> Package Manager Console)
  4. PM> scaffold controller Artist -DbContextType SiteDB -ReferenceScriptLibraries

Once it is done, open the ArtistsController.cs and go to line 56 which should look like:

public ActionResult Create(FormCollection collection)
	var item = new Artist();
        var whiteList = new string[] { "Name" }; // todo - add editable properties to this list
  1. Add any extra valid properties to the whitelist, e.g. var whiteList = new string[] { "Name", "Age" };
  2. also change the whitelist in the Edit HttpPost function on line 87.

Last edited May 29, 2011 at 12:06 PM by mattfrear, version 9


No comments yet.