views:

31

answers:

1

Hi All, I've been trying to wire up one of my projects to use Machine.Migrations for database migrations. However, I haven't been able to do that. I've been getting weird errors. I've tried using the MSBuild task but am getting the following error.

Target MigrationMachine:
  D:\repositories\core\playground\minhajuddin\MachineMigrationsTest\lib\Machine.Migrations.targets(20,5): error MSB4062: The "Machine.Migrations.MigratorTask" task could not be loaded from the assembly D:\repositories\core\playground\minhajuddin\MachineMigrationsTest\lib\Machine.Migrations.dll. Could not load file or assembly 'file:///D:\repositories\core\playground\minhajuddin\MachineMigrationsTest\lib\Machine.Migrations.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, and that the assembly and all its dependencies are available.
Done building target "MigrationMachine" in project "MachineMigrationsTest.csproj" -- FAILED.

When I try to use the migrate.exe. I get the following error:

INFO   Compiling Migration<1, CreateEmpTable>System.ArgumentException: Unable to locate Migration: 
D:\repositories\core\playground\minhajuddin\MachineMigrationsTest\MachineMigrationsTest\001_CreateEmpTable.cs    at Machine.Migrations.Services.Impl.MigrationHelpers.LookupMigration(Assembly assembly, MigrationReference migrationReference) in D:\repositories\os\machine.migrations\Source\Machine.Migrations\Services\Impl\BooMigrationFactory.cs:line 80   at Machine.Migrations.Services.Impl.CSharpMigrationFactory.CompileMigration(MigrationReference migrationReference) in D:\repositories\os\machine.migrations\Source\Machine.Migrations\Services\Impl\CSharpMigrationFactory.cs:line 71
   at Machine.Migrations.Services.Impl.AbstractMigrationCompilerFactory.CreateMigrationInstance(MigrationReference migrationReference) in D:\repositories\os\machine.migrations\Source\Machine.Migrations\Services\Impl\AbstractMigrationCompilerFactory.cs:line 9
   at Machine.Migrations.Services.Impl.CSharpMigrationFactory.CreateMigration(Mi
grationReference migrationReference) in D:\repositories\os\machine.migrations\So
urce\Machine.Migrations\Services\Impl\CSharpMigrationFactory.cs:line 35
   at Machine.Migrations.Services.Impl.MigrationRunner.CanMigrate(ICollection`1
steps) in D:\repositories\os\machine.migrations\Source\Machine.Migrations\Servic
es\Impl\MigrationRunner.cs:line 40
   at Machine.Migrations.Services.Impl.Migrator.RunMigrator() in D:\repositories
\os\machine.migrations\Source\Machine.Migrations\Services\Impl\Migrator.cs:line
39
   at Machine.Migrations.Migrator.Run(IConfiguration configuration) in D:\reposi
tories\os\machine.migrations\Source\Machine.Migrations\MigratorTask.cs:line 29
   at Machine.Migrations.ConsoleRunner.Program.Run(String[] args) in D:\reposito
ries\os\machine.migrations\Source\Machine.Migrations.ConsoleRunner\Program.cs:li
ne 38

Code in 001_create_emp_table.cs

namespace MachineMigrationsTest {
    public class CreateEmpTable : SimpleMigration {
        public override void Up() {
            Schema.AddTable("Emp",
                new Column[]
                    {
                        new Column("Id",ColumnType.Long,0,true,false)
                    });
        }

        public override void Down() {
            Schema.DropTable("Emp");
        }
    }


}

Please help me.

Thank you, Khaja Minhajuddin.

+1  A: 

Try naming your class the same as your file except for the version: create_emp_table

Edit: Also, try removing the namespace. I think MMigrations may require things to be in no namespace.

aaronjensen
Thanks for your help, that did fix the problem.
Khaja Minhajuddin