0

我收到运行 T4 模板的异常:

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)

这是我的 T4 文件:

<#@ 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();
#>

我添加了所有引用,例如: BLtoolkit.3 、 Bltoolkit.Data.DataProvider.MySql3 、 mysql.data 、 sys.data.linq 和 MySqlDataProvider.cs

4

1 回答 1

0

似乎无法实例化 MySQL 连接。我必须更正 MySql.ttinclude 文件:已更改

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

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

于 2012-02-06T17:08:13.300 回答