0

I am trying to use a template .tt file to create the table names for an api driven application. I can do this now with a static method as such. But obviously this is not very reusable.

public string[] GetEntities()
{
    return new string[] { "Entity01", "Entity02", "Entity03" }; 
} 

So what I am trying to accomplish is to allow my SqlFactory to go out and get my entities. This is what I was trying:

<#@ assembly name="$(SolutionDir)\MultiApiConnector\bin\SqlFactory.dll"#>    
<#+
public string[] GetEntities()
{
string hostName = ""; 
string dbName = "";
IDatabase database = DatabaseFactory.CreateDatabaseConnection("SqlServer", "Server=" + hostName + ";Integrated security=SSPI;database=" + dbName + ";");
return  database.GetRows;
}#>

Severity Code Description Project File Line Suppression State Error Compiling transformation: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. MultiApiConnector C:\Users\Dell\source\repos\MultiApiConnector\MultiApiConnector\Controllers\Common.tt 16

For my own edification I went out and did quite a number of searches about this error I looked in the current project to make sure that there was a reference to netstandard and there is. I went to the SqlFactory project and it is there as well under the sdk. I have looked into adding the netstandard to either solution and it is already there. Tried to add a reference to my config with no luck. I have searched stackoverflow for something similar to no avail. I am sure I am doing something wrong as I am new to templates. If you need any more information please let me know.

Reaper
  • 13
  • 5

1 Answers1

0

Add a netstandard reference to your template:

<#@ assembly name="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" #>
<#@ assembly name="$(SolutionDir)\MultiApiConnector\bin\SqlFactory.dll"#>
<#+
    public string[] GetEntities()
    ...
Murray
  • 1,948
  • 1
  • 12
  • 18