The code generated by scaffolding is controlled by a scaffold template. You identify which scaffold template to use when you run the scaffolding process. Refer to Invoking Scaffolders for more information.
Each template is implemented using the Microsoft Text Template Transformation Toolkit (T4). For more information on T4, search for the topic “Code Generation and T4 Text Templates” at http://msdn.microsoft.com.
Unisys supplies a number of scaffold templates. You can also define your own templates; refer to Creating Custom Scaffold Templates for more information.
WCF Service Template
See Unisys Data Source WCF Service Template below.
Controller Templates
See the following topics, below:
Unisys Data Source Web Controller Template
Unisys Data Source Web API Controller Template
View Templates
Unisys provides three different view scaffold templates. Each scaffold template generates markup that is designed to work with the bootstrap responsive framework (see http://getbootstrap.com).
All three view scaffold templates generate the same web pages at runtime by default. However, they vary by the amount of generation done at scaffold time and the amount of generation done at runtime. The advantage of generating most of the web page dynamically is that you can make changes to the client message without needing to perform scaffolding again. The advantage of generating most of the web page at scaffold time is that you have more power to customize the layout of the particular web page.
Refer to the following topics, below, for more information:
Unisys View Model Form (Bootstrap Form) Template
Unisys View Model Form (Bootstrap Form Groups) Template
Unisys View Model Form (Bootstrap Form Controls) Template
Unisys Data Source WCF Service Template
This scaffold template is used to generate a C# (.cs) file containing the WCF web service implementation, and a second C# (.cs) file containing the WCF web service interface.
The T4 file is located in the subfolder AddService under the folder CodeTemplates.
Unisys Data Source Web API Controller Template
This scaffold template is used to generate a C# (.cs) file containing the controller code for a Web API application that accesses an ePortal data source.
The T4 file is located in the subfolder AddController under the folder Code Templates.
Unisys Data Source Web API Core Controller Template
This scaffold template is used to generate a C# (.cs) file containing the controller code for a .NET Core Web API application that accesses an ePortal data source.
The T4 file is located in the subfolder AddController under the folder CodeTemplates.
Unisys Data Source Web Controller Template
This scaffold template is used to generate a C# (.cs) file containing the controller code for an MVC Web application that accesses an ePortal data source.
The T4 file is located in the subfolder AddController under the folder CodeTemplates.
Unisys View Model Form (Bootstrap Form) Template
This scaffold template generates a single C# razor (.cshtml) view file from the model class that is built from an ePortal client message. In particular, the generated razor file contains minimal markup, with most of the resulting web page generated dynamically at run time.
The T4 file is located in the subfolder AddView under the folder CodeTemplates.
The following example illustrates the output generated by this scaffold template (subject to change):
@model eBankDataSource.Client.BUFIN_TRANSFER_FUNDS @{ ViewBag.Title = @Html.DisplayNameForModel(); ViewData["ParentModel"] = Model; } @using (Html.BeginForm("BUFIN_TRANSFER_FUNDS", @ViewContext.RouteData.Values["controller"].ToString(), FormMethod.Post, new { id = "form0" })) { @Html.AntiForgeryToken() <div class="form-horizontal"> @Html.ValidationSummary(true) @Html.EditorForModel("BootstrapForm") </div> }
The key line above is the call to EditorForModel. EditorForModel generates an edit control at runtime for every applicable property in the model. In this case, the editor template BootstrapForm is invoked to perform the actual generation. Refer to http://msdn.microsoft.com/en-us/library/system.web.mvc.html.editorextensions.editorformodel(v=vs.118).aspx for more information.
Notes:
The generated razor view file contains very little code.
The details of what gets generated at run time is controlled by annotations in the model class that is built from the ePortal client message, as well as code in the BootstrapForm editor template.
You can make changes to the various Editor Templates to control the details of what gets generated if you do not like the defaults.
Reconcile Issues:
If you use this view scaffold template, you can make any modifications to any existing client message, and there is no need to rerun the view scaffolding.
If you add a new client message or delete an existing client message, refer to the topic Adding or Deleting Client Messages in Reconciling Client Message Changes to Scaffolded Presentation Projects.
Unisys View Model Form (Bootstrap Form Groups) Template
This scaffold template also generates a single C# razor (.cshtml) view file from the model class that is built from an ePortal client message. However, the generated razor file contains more markup than the Unisys View Model Form (Bootstrap Form) Template, including an EditorFor call for each applicable property.
The T4 file is located in the subfolder AddView under the folder CodeTemplates.
The following example illustrates the output generated by this scaffold template (subject to change):
@model eBankDataSource.Client.BUFIN_TRANSFER_FUNDS @{ ViewBag.Title = @Html.DisplayNameForModel(); ViewData["ParentModel"] = Model; } @using (Html.BeginForm("BUFIN_TRANSFER_FUNDS", @ViewContext.RouteData.Values["controller"].ToString(), FormMethod.Post, new { id = "form0" })) { @Html.AntiForgeryToken() <div class="form-horizontal"> @Html.ValidationSummary(true) @Html.EditorFor(m => m.TRANSFER_FUNDS.FROM_ACCOUNT, "BootstrapFormGroup") @Html.EditorFor(m => m.TRANSFER_FUNDS.TO_ACCOUNT, "BootstrapFormGroup") @Html.EditorFor(m => m.TRANSFER_FUNDS.AMOUNT, "BootstrapFormGroup") @Html.EditorFor(m => m.TRANSFER_FUNDS.RECURRING, "BootstrapFormGroup") @Html.EditorFor(m => m.TRANSFER_FUNDS.RECURRING_FREQUENCY, "BootstrapFormGroup") @Html.EditorFor(m => m.TRANSFER_FUNDS.EMAIL_CONFIRMATION, "BootstrapFormGroup") </div> }
The key lines above are the calls to EditorFor. EditorFor generates an edit control at runtime for one particular property in the model. In this case, the editor template BootstrapFormGroup is invoked to perform the actual generation. Refer to http://msdn.microsoft.com/en-us/library/system.web.mvc.html.editorextensions.editorfor(v=vs.118).aspx for more information.
Notes:
The generated razor view file still contains very little code; however, there is now code in the view for each applicable property in the client message.
When using this scaffold template, you have more control over the detailed format of the page. For example, you could add a special divider above the amount field along with some description of the expected format of the amount field.
The details of what gets generated at run time is controlled by annotations in the model class that is built from the ePortal client message, as well as code in the BootstrapFormGroup editor template.
You can make changes to the various editor templates to control the details of what gets generated if you do not like the defaults.
Reconcile Issues:
If you use this view scaffold template, you can make any modifications to any existing fields in existing client messages, and there is no need to rerun the view scaffolding.
If you add a new field to an existing client message, you must reconcile this with the corresponding view file. You can either rerun scaffolding for that view, (losing any custom changes you made to the view), or manually edit the view to add the new EditorFor call.
If you delete an existing field from an existing client message, you must reconcile this with the corresponding view file. You can either rerun scaffolding for that view, (losing any custom changes you made to the view), or manually edit the view to delete the corresponding EditorFor call.
If you add a new client message or delete an existing client message, refer to the topic Adding or Deleting Client Messages in Reconciling Client Message Changes to Scaffolded Presentation Projects.
Unisys View Model Form (Bootstrap Form Controls) Template
This scaffold template also generates a single C# razor (.cshtml) view file from the model class that is built from an ePortal client message. However, the generated razor file contains the most markup, including a label and validation for each property, along with bootstrap form group markup; the least amount of the page is generated dynamically at runtime.
The T4 file is located in the subfolder AddView under the folder CodeTemplates.
Here is some sample output generated by this scaffold template (subject to change):
@model eBankDataSource.Client.BUFIN_TRANSFER_FUNDS @{ ViewBag.Title = @Html.DisplayNameForModel(); ViewData["ParentModel"] = Model; } @using (Html.BeginForm("BUFIN_TRANSFER_FUNDS", @ViewContext.RouteData.Values["controller"].ToString(), FormMethod.Post, new { id = "form0" })) { @Html.AntiForgeryToken() <div class="form-horizontal"> @Html.ValidationSummary(true) <div class="form-group"> @Html.LabelFor(m => m.TRANSFER_FUNDS.FROM_ACCOUNT, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(m => m.TRANSFER_FUNDS.FROM_ACCOUNT) @Html.ValidationMessageFor(m => m.TRANSFER_FUNDS.FROM_ACCOUNT) </div> </div> <div class="form-group"> @Html.LabelFor(m => m.TRANSFER_FUNDS.TO_ACCOUNT, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(m => m.TRANSFER_FUNDS.TO_ACCOUNT) @Html.ValidationMessageFor(m => m.TRANSFER_FUNDS.TO_ACCOUNT) </div> </div> <div class="form-group"> @Html.LabelFor(m => m.TRANSFER_FUNDS.AMOUNT, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(m => m.TRANSFER_FUNDS.AMOUNT) @Html.ValidationMessageFor(m => m.TRANSFER_FUNDS.AMOUNT) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> @Html.EditorFor(m => m.TRANSFER_FUNDS.RECURRING) @Html.LabelFor(m => m.TRANSFER_FUNDS.RECURRING) @Html.ValidationMessageFor(m => m.TRANSFER_FUNDS.RECURRING) </div> </div> <div class="form-group"> @Html.LabelFor(m => m.TRANSFER_FUNDS.RECURRING_FREQUENCY, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(m => m.TRANSFER_FUNDS.RECURRING_FREQUENCY) @Html.ValidationMessageFor(m => m.TRANSFER_FUNDS.RECURRING_FREQUENCY) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> @Html.EditorFor(m => m.TRANSFER_FUNDS.EMAIL_CONFIRMATION) @Html.LabelFor(m => m.TRANSFER_FUNDS.EMAIL_CONFIRMATION) @Html.ValidationMessageFor(m => m.TRANSFER_FUNDS.EMAIL_CONFIRMATION) </div> </div> </div> }
For each applicable property, there is an entire bootstrap form-group generated directly into the razor file. The LabelFor call (refer to http://msdn.microsoft.com/en-us/library/system.web.mvc.html.labelextensions.labelfor(v=vs.118).aspx) generates the label for one property; EditorFor (refer to http://msdn.microsoft.com/en-us/library/system.web.mvc.html.editorextensions.editorfor(v=vs.118).aspx) generates an edit control at runtime for one particular property in the model. Since no editor template is explicitly specified in the EditorFor call, MVC will select an editor template which matches the name specified on the UIHint annotation. Refer to Overview of Scaffolding for more information.
Notes:
The generated razor view file now contains a lot of code.
When using this scaffold template, you have the most control over the detailed format of the page. For example, you could place from account and to account on the same line by placing both controls in the same form group.
The details of what gets generated at run time is controlled by annotations in the model class that is built from the ePortal client message, as well as code in the <uihintname> editor templates, where <uihintname> is the value you selected for the ControlStyle in the client message. Refer to Controlling the Look and Feel in All Data Source Projects.
You can make changes to the various Editor Templates to control the details of what gets generated if you do not like the defaults.
Reconcile Issues:
If you use this view scaffolder, you can still make most modifications to existing fields in existing client messages, and there is no need to rerun the view scaffolding.
However, changing the ControlStyle for an existing field in an existing client message may require you to reconcile your changes with the corresponding view file. For example, the format of the generated form group is different for CheckBox, Hidden and button list types compared with most of the other control styles. If you need to reconcile your changes, you can either rerun scaffolding for that view, (losing any custom changes you made to the view), or manually edit the view as needed.
If you add a new field to an existing client message, you must reconcile this with the corresponding view file. You can either rerun scaffolding for that view, (losing any custom changes you made to the view), or manually edit the view to add the new form-group div.
If you delete an existing field from an existing client message, you must reconcile this with the corresponding view file. You can either rerun scaffolding for that view, (losing any custom changes you made to the view), or manually edit the view to delete the corresponding form-group div.
If you add a new client message or delete an existing client message, refer to the topic Adding or Deleting Client Messages in Editor Templates.