tiene un error de compilación subsónico

I use visual studio 2010 and tried to use subsonic and i am getting the following error.

Error 2 Compiling transformation: Metadata file 'MySql.Data' could not be found D:\TradingTools\CODE\ConsoleApplication8\subsoniccomponents\Structs.tt 1 1 backtester

As you can see from the screenshot, i do have mysql.data in my references. i dunno how to fix this. Can you help fixing this problem. http://postimage.org/image/s1es0mr79/

preguntado el 25 de agosto de 12 a las 03:08

1 Respuestas

SubSonic uses the DbProviderFactory pattern. The DbProviderFactory approach allows the creation of Connections/Commands/... without knowning the concrete type.

// without factory
var con = new MySqlConnection();
var cmd = new MySqlCommand();

// with factory
var factory = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
var con = factory.CreateConnection();
var cmd = factory.CreateCommand();

which is a way more generic approach.

However, in order for this to work, you have to install MySql.Data (the msi-Package) which makes some entries in the machine.config archivo.

Dicho esto, las

I also prefer my build environment not to rely on installed software, which makes it a lot easier to switch to a new machine without installing multiple dependencies.

But this requires a little bit work:

Modify your app.config/web.config file and place this somewhere between <configuration> y </configuration>

  <system.data>
    <DbProviderFactories>
      <remove invariant="MySql.Data.MySqlClient"/>
      <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.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>
  </system.data>

I just copied and pasted the snippet from

%windir%\Microsoft.NET\Framework\<version>\Config

after installing the MSI.

If your solution has multiple projects, you have to do this for the main project (so subsonic can find your provider at runtime) and in your DAL project (so subsonic can find your provider during code generation).

If you use another MySQL Version you can change that.

The second thing you have to do is to tell the templates where to find the MySql.Data.dll (if it is not in the GAC).

You can do this by editing the MySQL.ttinclude file (look at the assembly directiva)

<#@ include file="Settings.ttinclude" #>
<#@ assembly name="$(SolutionDir)\Dependencies\MySql.Data.dll" #>
<#@ import namespace="MySql.Data.MySqlClient" #>
<#+

With these changes my solution runs find and template generation also works find on a clean install without any MySql Components installed.

Respondido el 07 de Septiembre de 12 a las 13:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.