Setup: Entity framework code first to new database.
Scenario: I'm playing around with EF and I add a bunch of elements to my database. I then change the entity model, and while I know that I could do migrations, I just want to start from scratch and basically wipe the database from the earth.
The database used by default was (localdb)\v11.0.
My question is:
Can I go somewhere and just delete a file, or start some kind of manager to delete that database and start from scratch?
Just go in command prompt with admin rights and type:
//list the instancies
sqllocaldb i
//stop selected instance
sqllocaldb p "selected instance"
//delete
sqllocaldb d "selected instance"
//recreate or create new one
sqllocaldb c "new instance"
From Visual Studio => Click View => SQL Server Object Explorer=> Right click the desired database and choose delete and it will be deleted or do whatever you want
If you're using Entity Framework Core, you can enter this in the Package Manager Console:
PM> Drop-Database
It will drop the current database. This command will tell you which one:
PM> Get-DbContext
This is also handy:
PM> Get-Help about_EntityFrameworkCore
I think you want to delete an individual database, not a LocalDB instance. If so, just issue a drop database command:
DROP DATABASE databasename;
You can do this from sqlcmd
, Management Studio, your application code, maybe even Visual Studio...
Yes you can. In VS 2015/2017 press Ctrl+Q, type "object explorer". The "SQL Server Object Explorer" should open, where you'll see your local DB instances. Expand the DB instance, and you'll see the different databases. Select one database perform a right click and choose "Delete".
For additional information check this link.
Hope that helps.
LocalDB is its own separate server (its name suggests that it is just a database in some other server instance but this is not the case). In SQL Server 2014 Express you connect to it using server name "(localdb)\MSSQLLocalDB", just as you would connect to any ordinary database server. If you connect using SQL Server Management Studio then you have all the power of SSMS available to you.