Project Description

A fast and customizable way to add Model (with optional Controller and Views) to your ASP.NET MVC project. You can specify property types or can use conventions.
Inspired by MvcScaffolding.

Project Objectives

Scaffold ASP.NET MVC extremely easy and fast way (at least for simple situations).


ModelScaffolding is the NuGet package that you can use with your Visual Studio 2010 projects.
The term “Scaffolding” is used by many software technologies to mean “quickly generating a basic outline of your software that you can then edit and customise”.
This package depends on MvcScaffolding.


  1. Install Package Manager Console (if you already installed ASP.NET MVC 3 you should already able to use Package Manager Console).
  2. Open the Package Manager Console window using View / Other Windows / Package Manager Console menu item and enter the following: Install-Package ModelScaffolding

You cannot use "Add Library Package Reference" dialog if you not have MvcScaffolding package installed, because it contains "init.ps1" file.

Model scaffolding

Model scaffolding performed by the TypeScaffolding NuGet package. You can visit the TypeScaffolding Project site to learn about parameters as well as output and conventions' customization.

Here is the simplest example:

PM> Scaffold Model Person Id,FirstName,LastName,BirthDate?

Let me explain to you what each part of this command:
  • Scaffold - command from T4Scaffolding NuGet package
  • Model - short name of the ModelScaffolding.Model scaffolder
  • Person - "Model" parameter for name of the newly created class
  • Id,FirstName,LastName,BirthDate? - "Properties" parameter for the Person's properties
  • Folder - this parameter is not used here, but you can specify folder for you class with it

The output file ([Models\]Person.cs) is as follows:

public class Person
	public int Id {get; set;}

	public string FirstName {get; set;}

	public string LastName {get; set;}

	public System.DateTime? BirthDate {get; set;}

You can do something more advanced like this:
PM> Scaffold Type MyModel Id,Name,Test?,ParentId,TestName[99],Count?,CreatedDate Models -Force
PM> Scaffold Type MyModel Id:long,Name:string[40],Count:long? Models -Force -NoAnnotations

Controller and Views scaffolding

You can use "-Controller" switch to scaffold not only model, but also controller and views.

Here is the simplest example:

PM> Scaffold Model Person Id,FirstName,LastName,BirthDate? -Controller

Controllers and views scaffolding performed by the MvcScaffolding NuGet package. You can read Steve Sanderson’s blog post to learn about parameters as well as output customization.
To cut a long story short, all appropriate parameters from ModelScaffolding passed to MvcScaffolding, except "Controller" and "ModelType".

If you already familiar with Entity Framework Code First and MVCScaffolding you should know, that we already created all the stuff to deal with "Person" table via the web interface.

Unable to cast object of type 'NuGet.SemanticVersion'

If you have this problem after installing new version of NuGet try this:
  • Uninstall NuGet
  • Install NuGet
  • Uninstall all Scaffolding packages (ModelScaffolding, MVCScaffolding...)
  • Install Scaffolding packages.

Last edited Jan 14, 2012 at 9:48 PM by OlegAxenow, version 14