Scaffold External DataModel

Jan 11, 2013 at 1:52 PM

I am looking to create Knockout files based on data models external to the project.

[T4Scaffolding.Scaffolder(Description = "Creates KnockoutJs models.")][CmdletBinding()]
param(
	[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)][object]$ModelType,
	[switch]$HasOptions,        
	[string]$Project,
	[string]$CodeLanguage,
	[string[]]$TemplateFolders,
	[switch]$Force = $false
)

Write-Host "Model Type: $ModelType"


# Ensure you've referenced System.Data.Entity
(Get-Project $Project).Object.References.Add("System.Data.Entity") | Out-Null
(Get-Project $Project).Object.References.Add("ISeries.Domain") | Out-Null

$outputPath = "Scripts\data\template\model.$ModelType"  # The filename extension will be added based on the template's <#@ Output Extension="..." #> directive
Write-Host "Output Path: $outputPath"
Write-Host "Project: $Project"

$foundModelType = (Get-ProjectType $ModelType -Project $Project -BlockUi)
$name = [string]($foundModelType.Name)

$pk = Get-PrimaryKey $ModelType
Write-Host "Primary Key: $pk"

Write-Host "Found Model Type Name: $name"
Write-Host "Found Model Type Full Name: $([string]($foundModelType.FullName))"

Add-ProjectItemViaTemplate $outputPath -Template knockoutTemplate `
	-Model @{ ModelType = $ModelType;ViewDataType = [MarshalByRefObject]$foundModelType;ViewDataTypeName = $foundModelType.Name;PrimaryKeyName = $pk;} `
	-SuccessMessage "Added kockout output at {0}" `
	-TemplateFolders $TemplateFolders -Project $Project -CodeLanguage $CodeLanguage -Force:$Force

 



The error I get is

Get-ProjectType : Cannot find a type matching the name 'ISeries.Domain.Entities.CapitalCredits.MembersCheckSummary'. Try specifying the fully-qualified type name, including namespace.
At C:\Users\tdemet\Documents\Visual Studio 11\Projects\MyAccount.Api\MyAccount.Api\CodeTemplates\Scaffolders\knockout\knockout.ps1:22 char:20
+ $foundModelType = (Get-ProjectType $ModelType -Project $Project -BlockUi)
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ProjectType], InvalidOperationException
    + FullyQualifiedErrorId : T4Scaffolding.Cmdlets.GetProjectTypeCmdlet