2013-03-28 48 views
0

得到下一execption嘗試使用MigratorDotNet到applay遷移:MigratorDotNet:沒有公共課與遷移屬性被發現

No public classes with the Migration attribute were found 

構建一般secceded,則不會出現配置錯誤。

我建立配置文件與一個內容:

<?xml version="1.0" encoding="utf-8"?> 
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 
    <PropertyGroup> 
     <ProjectRoot Condition="'$(ProjectRoot)' == ''">$([System.IO.Directory]::GetParent($(MSBuildProjectDirectory)))</ProjectRoot> 
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 
     <ClassLibraryOutputDirectory>bin\$(Configuration)</ClassLibraryOutputDirectory> 
     <MigrationsProject>$(ProjectRoot)\Solution\SqlMigrator\SqlMigrator.csproj</MigrationsProject> 
    </PropertyGroup> 

    <Import Project="Migrator.Targets" /> 

    <Target Name="Build-Migrations"> 
     <MSBuild Projects="$(MigrationsProject)" Targets="Build"> 
      <Output TaskParameter="TargetOutputs" ItemName="MigrationAssemblies" /> 
     </MSBuild> 

     <Message Text="Built: @(MigrationAssemblies)"/> 
    </Target> 

    <Target Name="Migrate" DependsOnTargets="Build-Migrations"> 
     <Message Text="Migrating: @(MigrationAssemblies)"/> 
     <Migrate Provider="MySql" 
      Connectionstring="server=localhost;User Id=root;password=;database=loveproject" 
      Migrations="@(MigrationAssemblies)" /> 
    </Target> 
</Project> 

我有一個測試遷移:

namespace SqlMigrator 
{ 
    using Migrator.Framework; 
    using System.Data; 

    [Migration(20140401110402)] 
    public class TestMigrate : Migration 
    { 
     public override void Up() 
     { 
      this.Database.ExecuteNonQuery(@"CREATE TABLE example (id INT, data VARCHAR(100));"); 
     } 

     public override void Down() 
     { 

     } 
    } 
} 

遷移的執行: C:\ WINDOWS \ Microsoft.NET \ Framework64 \ V4 .0.30319 \ MSBuild.exe mbuild.proj /噸:遷移

+0

你肯定對建設與移民類定義相同的程序集? – Rup

+0

說實話,我完全不確定我是這麼做的。這是我第一次使用msbuild腳本和migratordotnet。 :) –

回答

0

發現這個問題。問題出現在Project內部的Migrator版本中,我從msbuild調用。

我安裝的NuGet和下載的可執行文件的最新版本從網絡側到構建成的MSBuild(Migrator.MSBuild.dll)。這是在我的項目和msbuild腳本中使用的2個otehr版本。