代码之家  ›  专栏  ›  技术社区  ›  Khaja Minhajuddin

机器迁移连线。

  •  0
  • Khaja Minhajuddin  · 技术社区  · 15 年前

    我一直在尝试将我的一个项目连接到使用machine.migrations进行数据库迁移。但是,我一直没能做到。我犯了一些奇怪的错误。我已尝试使用msbuild任务,但收到以下错误。

    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.
    

    当我尝试使用migrate.exe时。我得到以下错误:

    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
    

    代码在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");
            }
        }
    
    
    }
    

    请帮帮我。

    谢谢您, 哈贾·米哈朱丁。

    1 回复  |  直到 11 年前
        1
  •  1
  •   Aaron Jensen    15 年前

    尝试将类命名为与文件相同的名称,但版本除外:create emp_table

    编辑:另外,尝试删除命名空间。我认为mmigration可能要求事物不在名称空间中。