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