2016-01-29 28 views
0

我有一個代碼,第一MVC網站,我得到這個錯誤,但我已經自動遷移開啓按下面的代碼:自創建數據庫以來,支持<Database>上下文的模型已更改。考慮使用的Code First遷移來更新數據庫

namespace KnightOwlMVC.Migrations 
{ 
    using System; 
    using System.Data.Entity; 
    using System.Data.Entity.Migrations; 
    using System.Linq; 

    internal sealed class Configuration : DbMigrationsConfiguration<KnightOwlMVC.Models.KnightOwlContext> 
    { 
     public Configuration() 
     { 
      AutomaticMigrationsEnabled = true; 
      AutomaticMigrationDataLossAllowed = true; 
     } 

     protected override void Seed(KnightOwlMVC.Models.KnightOwlContext context) 
     { 
      // This method will be called after migrating to the latest version. 

      // You can use the DbSet<T>.AddOrUpdate() helper extension method 
      // to avoid creating duplicate seed data. E.g. 
      // 
      // context.People.AddOrUpdate(
      //  p => p.FullName, 
      //  new Person { FullName = "Andrew Peters" }, 
      //  new Person { FullName = "Brice Lambson" }, 
      //  new Person { FullName = "Rowan Miller" } 
      // ); 
      // 
     } 
    } 
} 

我已經運行更新DB以下,但我仍然得到同樣的錯誤:

Update-Database -ConnectionStringName DefaultConnection 
+0

運行update-database -verbose查看它正在嘗試執行的操作或切換到手動遷移。您還可以運行update-database -force來強制更新。 –

回答

0

通過做一個真正的下來,ditry方式並刪除數據庫,並再次啓動修復了這個到底。我認爲這是一款開發中的應用程序,但顯然我不會推薦這種生產方式。

相關問題