We have an ASP.NET Core MVC application with Entity Framework Core in it. We have added a custom
Testing environment to the existing
Production environments. Now, we would like the application to drop and recreate (or at least truncate) the database every time the application starts in this new Testing environment.
Is there an automated way how to achieve this behavior? Or do I have to manually call
RemoveAll on each
DbSet in the database context?
Ensures that the database for the context does not exist. If it does not exist, no action is taken. If it does exist then the database is deleted.
Warning: The entire database is deleted an no effort is made to remove just the database objects that are used by the model for this context.
dbContext.Database.Migrate() to create new (empty) DB and migrate to latest version.