EF6 migrations (LocalDb) update-database login failed

asp.net-mvc-5 ef-migrations entity-framework localdb

Accepted Answer

ZZZ_tmp
15
5/23/2017 10:30:12 AM

Popular Answer

I'm using VS 2013 and EF6.1 for my job.

Whenever I deal with migration and destroy databases, I encounter a same error. I couldn't make the database again. The local SQLExpress database instance that was causing the problem was running in the background and still using the connection to the deleted database.

The steps to handle this scenario are shown below.

  1. The database files (.mdf and.ldf) should be deleted.
  2. Migration Folder should be removed from your application.
  3. Delete all instances of that database's connections from server Explorer's data connections.
  4. Activate the Windows Command Prompt (IF VS 2012 or earlier you have to use the VS Command prompt).
  5. Activate "sqllocaldb.exe stop v11.0" (This will stop the v11.0 service)
  6. Run the SQLlocalDB.EXE delete v11.0 command (This will delete the v11.0 service)
  7. open Visual Studio's Package Manager Console.
  8. Run the migrations command (This will create Migration folder and content)
  9. Activate "Add-Migration init" (This will scaffold the changes to next migration)
  10. Activate "Update-Database" (This will create the database again)


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow