Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF5 Migration Update-Database -Script Error

I've been using Visual Studio 2012 RC with trial license with no problems. I purchased Visual Studio 2012 Professional yesterday, installed the latest version, and installed Update 1.

I have a solution/project I've been working on for many years. It has many migrations in it. I ran my first add-migration TableX_NewField and update-database -sourcemigration:TableX_PreviousNewField in this latest version.

They both ran with no problems.

Then I ran update-database -script -sourcemigration:TableX_PreviousNewField and received the following:

PM> update-database -script -sourcemigration:TableX_PreviousNewField Applying code-based migrations: [201301151003149_TableX_NewField]. Applying code-based migration: 201301151003149_TableX_NewField. System.Runtime.InteropServices.COMException (0x8004000C): User canceled out of save dialog (Exception from HRESULT: 0x8004000C (OLE_E_PROMPTSAVECANCELLED))   at EnvDTE.ItemOperations.OpenFile(String FileName, String ViewKind)   at System.Data.Entity.Migrations.Utilities.DomainDispatcher.OpenFile(String fileName)   at System.Data.Entity.Migrations.Utilities.DomainDispatcher.OpenFile(String fileName)   at System.Data.Entity.Migrations.Extensions.ProjectExtensions.NewSqlFile(Project project, String contents)   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) User canceled out of save dialog (Exception from HRESULT: 0x8004000C (OLE_E_PROMPTSAVECANCELLED)) 

I've ran windows updates. Checked updates with NuGet. Restarted my computer. Still have error.

like image 874
Sean Newcome Avatar asked Jan 15 '13 12:01

Sean Newcome


People also ask

How do I update my database in migration?

After creating a migration file using the add-migration command, you have to update the database. Execute the Update-Database command to create or modify a database schema. Use the –verbose option to view the SQL statements being applied to the target database.

How do I update my EF core model after database change?

Right-click anywhere on the design surface, and select Update Model from Database... In the Update Wizard, select the Refresh tab and select your table then click Finish button.

How do I delete migration after update database?

Delete your Migrations folder. Create a new migration and generate a SQL script for it. In your database, delete all rows from the migrations history table. Insert a single row into the migrations history, to record that the first migration has already been applied, since your tables are already there.


2 Answers

I noticed in visual studio, going to SQL menu, Transact-SQL Editor, New Query... gave a dialog about the tools not working with the server installed. Installing SQL Server Data Tools - December 2012 update (Sql Server Data Tools) fixed the problem

like image 158
James Harrison Avatar answered Oct 10 '22 10:10

James Harrison


This issue is resolved. I uninstalled and then installed and the problem was not resolved. I then did two things at the same time; so I do not know which resolved the issue:

  1. Deleted all folders and files in %temp%.
  2. Ran devenv /resetsettings.

Hope this helps anyone who runs into a similar issue.

like image 40
Sean Newcome Avatar answered Oct 10 '22 10:10

Sean Newcome