Answer by Zahari Kitanov for How to delete and recreate from scratch an...
I am using .net Core 6 and this code is directly stripped out of the Program.csusing Microsoft.EntityFrameworkCore;namespace RandomProjectName{ public class Program { public static async...
View ArticleAnswer by Jack Miller for How to delete and recreate from scratch an existing...
Using EF6 with ASP.Net Core 5 I found these commands handy during first initialization of the database:Remove-Migration -force; Add-Migration InitialMigration; Update-Database;It removes the last...
View ArticleAnswer by Samithe Adhikari for How to delete and recreate from scratch an...
There re many ways to drop a database or update existing database, simply you can switched to previous migrations.dotnet ef database update previousMigraionName But some databases have limitations like...
View ArticleAnswer by Albert Quist for How to delete and recreate from scratch an...
Let me help in updating the answers here since new users will find it useful.I believe the aim is to delete the database itself and recreate it using EF Code First approach.1.Open your project in...
View ArticleAnswer by beggarboy for How to delete and recreate from scratch an existing...
Since this question is gonna be clicked some day by new EF Core users and I find the top answers somewhat unnecessarily destructive, I will show you a way to start "fresh". Beware, this deletes all of...
View ArticleAnswer by Greck for How to delete and recreate from scratch an existing EF...
dbctx.Database.EnsureDeleted();dbctx.Database.EnsureCreated();
View ArticleAnswer by Gizmo3399 for How to delete and recreate from scratch an existing...
For EntityFrameworkCore you can use the following:Update-Database -Migration 0This will remove all migrations from the database.Then you can use:Remove-MigrationTo remove your migration.Finally you can...
View ArticleAnswer by Florian Winter for How to delete and recreate from scratch an...
If you created your database following this tutorial: https://msdn.microsoft.com/en-au/data/jj193542.aspx... then this might work:Delete all .mdf and .ldf files in your project directoryGo to View /...
View ArticleAnswer by Shaahin for How to delete and recreate from scratch an existing EF...
Take these steps:Delete those object which should be deleted from the context // Dbset<Item> Items{get;set;}and in Nuget Console run these commandsadd-migration [contextName] update-database...
View ArticleAnswer by Amadeo Gallardo for How to delete and recreate from scratch an...
Single Liner to Drop, Create and Seed from Package Manager Console: update-database -TargetMigration:0 | update-database -forceKaboom.
View ArticleAnswer by SAm for How to delete and recreate from scratch an existing EF Code...
How about ..static void Main(string[] args){ Database.SetInitializer(new DropCreateDatabaseIfModelChanges<ExampleContext>()); // C // o // d // i // n // g}I picked this up from Programming...
View ArticleAnswer by Daf De Giraf for How to delete and recreate from scratch an...
If you worked the correct way to create your migrations by using the command Add-Migration "Name_Of_Migration" then you can do the following to get a clean start (reset, with loss of data, of...
View ArticleAnswer by NSGaga-mostly-inactive for How to delete and recreate from scratch...
If I'm understanding it right... If you want to start clean: 1) Manually delete your DB - wherever it is (I'm assuming you have your connection sorted), or empty it, but easier/safer is to delete it...
View ArticleHow to delete and recreate from scratch an existing EF Code First database
I am using EF Code First with EF 5 in VS 2012. I use PM update-database command and I have a simple seed method to fill some tables with sample data.I would like to delete and recreate my x.mdb. The...
View Article
More Pages to Explore .....