Question

How do you use the --connectionStringConfigPath for FluentMigrator when using the MSBuild runner?

The documentation says

Connection (required)

The connection string to the server and database you want to execute your migrations against. This can be a full connection string or the name of the connection string stored in a config file.

When specifying a named connection string, FluentMigrator searchs for it in this order:

  1. The specified config file via --connectionStringConfigPath parameter
  2. Target assembly’s config file
  3. Machine.config config file

I was not able to get this to work and couldn't find any examples of usage with FluentMigrator's MSBuild runner.

Was it helpful?

Solution

The connectionStringConfigPath parameter is used in conjuction with the Connection parameter. The Connection parameter specifies the name of the connection string.

This is an example of the migrate task:

<Migrate Database="sqlserver2012"
    Connection="SRVConnectionString"
    ConnectionStringConfigPath="db.config"
    Target="./Migrations/bin/Debug/Migrations.dll">
</Migrate>

And this is the db.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <connectionStrings>
        <clear />
        <add name="SRVConnectionString" connectionString="server=SQLEXPRESS;uid=test;pwd=test;database=Test"/>
    </connectionStrings>
</configuration>

I will update the wiki with this example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top