CodeSmith连接Mysql方法步骤

版本信息:

1. codesmith 7.0

2. mysql-connector-net-6.7.4.msi

文件:CodeSmith.exe.config 内容

<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <system.data>
	 <DbProviderFactories> 
		<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" /> 
	 </DbProviderFactories> 
  </system.data>
  <system.diagnostics>
    <switches>
      <add name="CodeSmithSwitch" value="4" />
    </switches>
  </system.diagnostics>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="bin;AddIns;SchemaProviders"/>
      <dependentAssembly>
        <assemblyIdentity name="Ionic.Zip.Reduced" publicKeyToken="edbe51ad942a3f5c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.9.1.8" newVersion="1.9.1.8" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
其中System.data段为连接mysql的配置项

还需要安装mysql-connector-net-6.7.4.msi.

然后将C:\ProgramFiles (x86)\MySQL\MySQL Connector Net 6.7.4\Assemblies\v4.5\MySql.Data.dll 复制到CODESMITH_HOME\bin

启动CodeSmith并在schemaexplorer中添加mysql的连接

联接字符串:

server=127.0.0.1;userid=root;persist security info=True;database=testDB


TemplateEditor.exe.config等其它配置文件的内容参见CodeSmith.exe.config




版权声明:本文为博主原创文章,未经博主允许不得转载。

你可能感兴趣的:(codesmith,codegen)