2017-08-17 33 views
-1

未決遷移當運行命令Update-Database,得到一個錯誤:如何找到的EntityFramework

Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.

You can use the Add-Migration command to write the pending model changes to a code-based migration.

當運行Add-Migration命令,得到了實體遷移,這是在之前刪除承諾源。刪除SQL數據庫,將新鮮的代碼放入乾淨的目錄中,檢查上下文中是否存在實體。

嘗試運行Update-Database時仍然出現相同的錯誤。如何找出這個被刪除的實體在哪裏仍然被記住,並將其徹底刪除?

試過Update-Database -Script,卻得到了消息

The EntityFramework package is not installed on project

+0

解決方法是刪除上面的遷移和重新運行命令。刪除的實體存儲在二進制文件中用於最新的遷移。 – bonafiden

回答

0

解決辦法是刪除之前的遷移和上述重新運行命令。刪除的實體存儲在二進制文件中用於最新的遷移。