I am trying to connect to my Postgres database in my T4 file using the following code:
<#@ template language="C#" debug="True" hostSpecific="True" #>
<#@ output extension=".cs"#>
<#@ include file="$(LinqToDBT4PostgreSQLTemplatesDirectory)LinqToDB.PostgreSQL.Tools.ttinclude" #>
<#@ include file="$(LinqToDBT4PostgreSQLTemplatesDirectory)PluralizationService.ttinclude" #>
<# //@ include file="$(ProjectDir)LinqToDB.Templates\LinqToDB.PostgreSQL.Tools.ttinclude" #>
<# //@ include file="$(ProjectDir)LinqToDB.Templates\PluralizationService.ttinclude" #>
<#
LoadPostgreSQLMetadata("localhost", "5433", "local_db", "postgres", "password");
GenerateModel();
#>
When I save the file in Visual Studio 2019, I get the following error:
Compiling transformation: 'ISqlBuilder' does not contain a definition for 'BuildTableName' and no
accessible extension method 'BuildTableName' accepting a first argument of type 'ISqlBuilder' could
be found (are you missing a using directive or an assembly reference?)
This is my first foray into using Linq2DB in T4, normally I have used SQL Server using SQLClient, but this project is using Postgres v11 and v14.
I am sure that it is something the I have not configured.
I have followed the following:
Can't generate data context with t4 template. PostgreSQL + MySql
Not 100% sure what the versions have to do with it, but here goes:
- Visual Studio 2019 (Version 16.11.15)
- Linq2Db installed from NuGet. Latest
- Linq2Db.Postgres installed from NuGet. Lastest
- NgpSQL installed from Nuget. Latest
UPDATE
I now have it working, but all I am interested in is generating enums from my database, I do not need it to generate a complete db context.
Is that possible?