Search code examples
visual-studio-2013fluent-migrator

How do i run Fluent Migrator within visual studio 2013


I created a Migration in visual studio I added Fluent Migrator to my project with Nuget, but how do I run the migration to add the tables and columns to my database?


Solution

    1. First, we install the Fluent Migrator Tools nuget package inside our Migrations project. This will download and extract a Migrate.exe executable. This executable can be used to execute your migrations from the command line, exactly what we need
    2. Add the Migrate.exe and the FluentMigrator.Runner.dll assemblies to your project by right-clicking on the project and selecting Add an existing item. Navigate to the packages folder of your solution and pick the Migrate.exe and the FluentMigrator.Runner.dll that are somewhere inside the FluentMigrator.Tools folder. Make sure you select Add as link
    3. Open up the properties for the Migrate.exe and FluentMigrator.Runner.dll items in your Visual Studio project, and set it to Copy to output directory: Copy always
    4. Our project is now in the perfect shape to make an external tool consume it. Open up the external tools manager and create a new tool. Give it the following values.
    Title: FluentMigrate
    Command: $(BinDir)\Migrate.exe
    Arguments: --provider sqlserver2008 --a $(TargetName)$(TargetExt)
    Initial Directory: $(BinDir)
    Use output window: click checkbox
    

    More Info