Understanding MM .NET Item Templates
When you right-click a project and select Add | New Item... from the shortcut menu, it displays the Add New Item dialog. In the left pane, select your language of choice and the, MM .NET templates are displayed in the Templates pane:

Note: If you can't see the MM .NET item templates, check out the Help topic Why can't I see the MM .NET Project and Item Templates?
As you select each template a description of the template is displayed under the templates list and a default class name is displayed in the Name text box. This topic tells you the steps it takes to display custom templates in this dialog.
Item Template Zip Files
When you install MM .NET on your computer, an MM .NET Templates extension set is installed in the following directory:%USERPROFILE%\Documents\Visual Studio 2026\Templates\ItemTemplates\OakLeafHere is a screen shot of the some of template file folders:

When you launch the Add New Item dialog, Visual Studio searches this directory (among others) for templates. Template folders contain one .vstemplate file and one or more source code files. For example, the MMBusinessObject folder contains these files:

And the MMWPFBusinessWindow folder contains these files:

Visual Studio Template Files
Visual Studio .vstemplate files contain information that instructs Visual Studio how to display a template in the Add New Item dialog and what actions to perform when a new item is added to a project from the template.For example, here is the contents of the MMBusinessObject.vstemplate file:
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"> <TemplateData>
<Name ID="2245">MM .NET Business Object</Name>
<Description>MM .NET Business Object</Description>
<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4515" />
<ProjectType>CSharp</ProjectType>
<SortOrder>4</SortOrder>
<DefaultName>BusinessObject.cs</DefaultName>
</TemplateData>
<TemplateContent>
<References>
<Reference>
<Assembly>System</Assembly>
</Reference>
<Reference>
<Assembly>System.Data</Assembly>
</Reference>
<Reference>
<Assembly>System.Xml</Assembly>
</Reference>
<Reference>
<Assembly>OakLeaf.MM2026.Interfaces.Standard</Assembly>
</Reference>
<Reference>
<Assembly>OakLeaf.MM2026.Framework.Standard</Assembly>
</Reference>
</References>
<ProjectItem ReplaceParameters="true">MMBusinessObject.cs</ProjectItem>
<ProjectItem ReplaceParameters="true">MMBusinessObject.Partial.cs</ProjectItem>
<CustomParameters>
<CustomParameter Name="$createbusinessrule$" Value=""/>
<CustomParameter Name="$basefullname$" Value="ABusinessObject"/>
<CustomParameter Name="$entityobject$" Value=""/>
<CustomParameter Name="$ruleobject$" Value=""/>
<CustomParameter Name="$defaultvaluesobject$" Value=""/>
<CustomParameter Name="$hooksetdefaultvalues$" Value=""/>
<CustomParameter Name="$beginassociationregion$" Value=""/>
<CustomParameter Name="$endassociationregion$" Value=""/>
<CustomParameter Name="$setdefaultcommandtype$" Value=""/>
<CustomParameter Name="$dataaccessobject$" Value=""/>
<CustomParameter Name="$createdataaccessobject$" Value=""/>
<CustomParameter Name="$genericentitytype$" Value="<ABusinessEntity>"/>
<CustomParameter Name="$objectcontext$" Value=""/>
<CustomParameter Name="$entityframeworkproperty$" Value=""/>
<CustomParameter Name="$createobjectcontext$" Value=""/>
</CustomParameters>
</TemplateContent>
</VSTemplate>Specifying Display Information with the <TemplateData> Element
The <TemplateData> element contains information that tells Visual Studio how to display the template in the Add New Item dialog. Here is a rundown of its sub-elements:
| Element | Description |
|---|---|
| Name | The name displayed under the template icon in the dialog |
| Description | The description displayed at the bottom of the dialog when the template is selected |
| Icon | The icon displayed for the template in the dialog |
| ProjectType | The type of project (CSharp, VisualBasic, etc.) the template is associated with |
| SortOrder | A relative number that specifies the order in which the template is displayed in the dialog |
| DefaultName | The default name of a new item created from the template. This is displayed in the Name text box of the dialog |
Specifying Dependent Assemblies with the <References> Element
The <References> element (nested within the <TemplateContent> element) allows you to specify .NET assemblies that must be referenced in the project when a new item is added to the project from the template. This is an extremely useful feature of template files. For example, in the MMBusinessObject.vstemplate file shown above, the following assembly dependencies are specified:- System
- System.Data
- System.Xml
- MM .NET Framework Interfaces
- MM .NET Framework
When Visual Studio adds a new business object to a project based on this template, it checks if the specified assemblies are already referenced in the project. If not, it automatically adds a reference to these assemblies for you.
Specifying Template Source Code Files with the <ProjectItem> Element
The <ProjectItem> element (nested within the <TemplateContent> element) specifies the source code files that are added to the project when a new item is added. There is one <ProjectItem> element for each source code file. For example, the MMBusinessObject.vstemplate file specifies two source code file:<ProjectItem ReplaceParameters="true">MMBusinessObject.cs</ProjectItem>
<ProjectItem ReplaceParameters="true">MMBusinessObject.Partial.cs</ProjectItem>The MMWPFBusinessWindow template file also specifies two source code files:
<ProjectItem SubType="Designer" TargetFileName="$fileinputname$.xaml" ReplaceParameters="true">MMWPFBusinessWindow.xaml</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.xaml.cs" ReplaceParameters="true">MMWPFBusinessWindow.xaml.cs</ProjectItem>Replacing Parameters in Template Source Code Files
Notice the <ProjectItem> elements shown in the previous section have a ReplaceParameters attribute that is set to "true". This tells Visual Studio to search the source code files for parameter tokens and replace them with specified values when adding the source code files to the project.
For example, here is the MMBusinessObject.cs template source code file:

The text strings contained within "$" signs are parameter tokens. In this example, the $rootnamespace$ and $safeitemrootname$ tokens are built-in parameters used by Visual Studio to indicate the project's default namespace (C#) or root namespace (VB .NET). When the source code file is added to the project, VS replaces this token with the specified namespace. The $safeitemrootname$ token is the name the user specified for the class in the Add New Item dialog. Again, Visual Studio replaces this token with the specified class name.
The other tokens are for custom parameters unique to MM .NET.
Specifying Custom Parameters in Template Files
The <CustomParameters> element (nested within the <TemplateContent> element) allows you to specify your own custom parameters in template source code files. For example, the MMBusinessObject.vstemplate file contains these custom parameter declarations:<CustomParameters>
<CustomParameter Name="$createbusinessrule$" Value=""/>
<CustomParameter Name="$basefullname$" Value="ABusinessObject"/>
<CustomParameter Name="$entityobject$" Value=""/>
<CustomParameter Name="$ruleobject$" Value=""/>
<CustomParameter Name="$defaultvaluesobject$" Value=""/>
<CustomParameter Name="$hooksetdefaultvalues$" Value=""/>
<CustomParameter Name="$beginassociationregion$" Value=""/>
<CustomParameter Name="$endassociationregion$" Value=""/>
<CustomParameter Name="$setdefaultcommandtype$" Value=""/>
</CustomParameters>The <CustomParameter> sub-element specifies the token for the custom parameter and the value to be inserted in place of the token when the source code file is added to the project. In this case the text "ABusinessObject" is used to replace the $basefullname$ token (this specifies the default base class of the new business object) and an empty string is used to replace all other tokens.
Templates in Action
To better understand how templates work, here is a step-by-step demonstration of adding a new item to a project:- Right-click a project and select Add | New Item... from the shortcut menu.
- In the Add New Item dialog, select the MM .NET node in the Categories pane and then select the MM .NET Business Object template:

Notice the description "MM .NET Business Object" is displayed beneath the templates box as specified in the <Description> element of the MMBusinessObject.vstemplate file. Also notice the default name of the class is BusinessObject1.cs which was specified by the <DefaultName> element.
- If you change the name of the class to Inventory.cs and click the Add button, here is the resulting source code added to the project:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using OakLeaf.MM.Main.Business; using OakLeaf.MM.Main.Collections; using OakLeaf.MM.Main.Data; namespace OakLeaf.MM.Main.Business { /// <summary> /// Summary description for Inventory. /// </summary> public partial class Inventory : ABusinessObject<ABusinessEntity> { /// <summary> /// Constructor /// </summary> public Inventory() { this.TableName = ""; this.PrimaryKey = ""; this.HookConstructor(); this.EntityCentric = true; } } }Note the following:
- The $rootnamespace$ token has been replaced with the project's default namespace OakLeaf.MM.NorthwindSample
- The $safeitemrootname$ token has been replaced by Inventory (the name specified in the Add Item dialog)
- The $basefullname$ token has been replaced by ABusinessObject as specified in the template file.
- All other tokens have been replaced by an empty string
- The $rootnamespace$ token has been replaced with the project's default namespace OakLeaf.MM.NorthwindSample
Updating Visual Studio's Item Template Cache
After creating new item templates or changing existing templates, you must update Visual Studio's item template cache. To do this, exit Visual Studio, and launch a Visual Studio Developer Command Prompt (you must launch the Command Prompt with Run as Administrator).In the command prompt dialog, enter the following command, then press Enter:
DEVENV /SETUP
This command causes Visual Studio to examine the template folders and add them to its template item cache. This process takes several seconds to complete.
See also:
Understanding MM .NET Project Templates
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 02/12/26
Comment or report problem with topic
