2012-08-10 49 views
1

我试图部署这是越来越在App海底下面的生成错误的实例部署数据库无法在App港

Build FAILED. 

"D:\temp\gcp22bmp.ggi\input\src\ShareBill.sln" (default target) (1) -> 
"D:\temp\gcp22bmp.ggi\input\src\Sharebill.Database\Sharebill.Database.dbproj" (default target) (5) -> 
    D:\temp\gcp22bmp.ggi\input\src\packages\TeamData\Microsoft.Data.Schema.SqlTasks.targets(5,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.TSqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [D:\temp\gcp22bmp.ggi\input\src\Sharebill.Database\Sharebill.Database.dbproj] 

    0 Warning(s) 
    1 Error(s) 

我知道这是因为通常存在这里的SQL目标 - Ç :\ Program Files(x86)\ MSBuild \ Microsoft \ VisualStudio \ v10.0 \ TeamData

不存在于部署服务器上。

现在应该怎么做才能部署数据库?有没有其他的方式来部署数据库。我在EF中没有先使用代码,但我仍然希望自动应用db迁移。

我假设如果我得到的数据库项目运行它会自动找到架构差异并将更改应用到数据库。

+0

我还没有使用的数据库项目,但如果你已经使用实体框架,这种方法可能会更好:http://blog.appharbor.com/2012/04/24/automatic-migrations-with-entity-framework-4-3 – friism 2012-08-10 07:08:59

+0

谢谢,我已经阅读过这个文档。我想知道它是否也适用于我,因为我在EF中使用Model第一种方法,而不是第一种方法。 – Tushar 2012-08-10 07:34:54

回答

0

我在AppHarbor上托管一个项目,并使用FluentMigrator来部署我的数据库更改。

实现起来非常简单,只需按照documentation即可使用流畅的界面,甚至只是用它来执行sql。

当我逃离我的我的Global.asax.cs中的Application_Start下面的例子 - 只是把你的迁移在同一组件设置为NOP MigrationMarker类:​​

 const string connectionString = @"Data Source=localhost, 1433;Initial Catalog=testdb;Integrated Security=SSPI;"; 
     Announcer announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s)); 
     announcer.ShowSql = true; 

     var assembly = Assembly.GetAssembly(typeof(MigrationMarker)); 
     var migrationContext = new RunnerContext(announcer); 

     var options = new ProcessorOptions 
          { 
           PreviewOnly = false, // set to true to see the SQL 
           Timeout = 60 
          }; 

     var factory = new SqlServer2008ProcessorFactory(); 
     var processor = factory.Create(connectionString, announcer, options); 
     var runner = new MigrationRunner(assembly, migrationContext, processor); 

     runner.MigrateUp(true); 
+0

我不是100%确定这适用于所问的问题。 – 2013-06-15 23:48:26