BLToolkit + T4 generation + MySQL database

1k views Asked by At

I receive an exception running my T4 template:

Running transformation: System.ArgumentNullException: Value cannot be null.
Parameter name: type
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at Microsoft.VisualStudio.TextTemplatingB9C41E12E53D4F3972EB874C0B96FDFD.GeneratedTextTransformation.GetConnection()
   at Microsoft.VisualStudio.TextTemplatingB9C41E12E53D4F3972EB874C0B96FDFD.GeneratedTextTransformation.LoadServerMetadata()
   at Microsoft.VisualStudio.TextTemplatingB9C41E12E53D4F3972EB874C0B96FDFD.GeneratedTextTransformation.LoadMetadata()
   at Microsoft.VisualStudio.TextTemplatingB9C41E12E53D4F3972EB874C0B96FDFD.GeneratedTextTransformation.GenerateModel()
   at Microsoft.VisualStudio.TextTemplatingB9C41E12E53D4F3972EB874C0B96FDFD.GeneratedTextTransformation.TransformText()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)

this is my T4 file:

<#@ template language="C#v3.5"         #>
<#@ output extension=".generated.cs"   #>
<#@ include file="BLToolkit.ttinclude" #>
<#@ include file="MySql.ttinclude"    #>
<#
    ConnectionString     = "Server=localhost;Port=3306;Database=accounting;Uid=root;pwd=1;";
    DataProviderAssembly = @"D:\Temp\BLToolKitMySql\BLToolKitMySql\mysql.data.dll";

    Namespace       = "BLToolKitMySql";
    DataContextName = "DataModel";
    GenerateModel();
#>

I added all references like: BLtoolkit.3 , Bltoolkit.Data.DataProvider.MySql3 , mysql.data , sys.data.linq and MySqlDataProvider.cs

1

There are 1 answers

0
McX On BEST ANSWER

It seems that the MySQL connection can't be instanciated. I had to correct the MySql.ttinclude file : changed

ConnectionType = "MySql.Data.MySqlClient.MySqlConnection, MySql.Data";

to

ConnectionType = "MySql.Data.MySqlClient.MySqlConnection, mysql.data";