I am new to this T4 Templates. All i know is these templates will generate entity classes from a LINQ to SQL class model (.dbml file) We have this system which runs on Visual Studio 2010.
The problem starts, when we migrate to Visual Studio 2015. I want to add new column to the entity/table. When i Run Custom Tool, this error pops
A processor named 'T4Toolbox.XsdProcessor' could not be found for the directive named 'xsd'. The transformation will not be run. The following Exception was thrown: System.IO.FileNotFoundException: Failed to resolve type for directive processor T4Toolbox.XsdProcessor.
Below is the template.
<#@ template hostspecific="True" debug="true" #>
<#@ xsd processor="T4Toolbox.XsdProcessor" file="%VS100COMNTOOLS%\..\..\Xml\Schemas\DbmlSchema.xsd" #>
<#@ output extension="log" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ include file="T4Toolbox.tt" #>
<#
@ include file="..\..\..\Framework\Templates\LinqToSql.tt" #>
// <copyright file="Script1.tt" company="">
// Copyright © . All Rights Reserved.
// </copyright>
// Generate entity classes from a LINQ to SQL class model (.dbml file)
NXpertGenerator generator = new NXpertGenerator();
generator.DbmlFile = "..\\..\\NXpert.Accounting.DataAccess\\Accounting.dbml";
generator.ConnectionStringKey = "AccountingDB2";
generator.DbmlNamespace = "NXpert.Accounting.DataAccess";
generator.UsingStatements = new List<string>{"NXpert.Core", "NXpert.Accounting", "NXpert.Accounting.DataAccess", "System.Data.Linq"};
generator.ClassMappings = new List<ObjectDescriptor>{
new ObjectDescriptor{
Name = "BalanceSheet",
NamePlural = "BalanceSheets",
EntityName = "BalanceSheetEntity",
Properties = new List<PropertyDescriptor>{
new PropertyDescriptor{ Name = "Status", ConvertType = "CommonStatus" },
new PropertyDescriptor{ Name = "CreatedDate", ConvertType = "DateTime" },
new PropertyDescriptor{ Name = "UpdatedDate", ConvertType = "DateTime" }
}
}
};
generator.Run();
#>
I did try to remove the line
<#@ xsd processor="T4Toolbox.XsdProcessor" file="%VS100COMNTOOLS%\..\..\Xml\Schemas\DbmlSchema.xsd" #>
This error shows
Compiling transformation: The type or namespace name 'Association' could not be found (are you missing a using directive or an assembly reference?) Compiling transformation: The type or namespace name 'Database' could not be found (are you missing a using directive or an assembly reference?)
Somewhat this kind of error tells me that it is just a namespace that i forgot to add. But again this template is running perfectly in Visual Studio 2010.
There must be some settings/ steps to be done in order for these templates to run in VS2015. Please let me know.
I would gladly appreciate any solution or idea you can share to this problem of mine.