I'm trying to delete the created database, but I'm getting exception that the database is in use by this application. After executing this code, an exception is thrown: System.IO.IOException: The process cannot access the file because the file is being used by another process.
var context= new StorageDBcontext();
File.Delete(AppSettings.StorageDBPath()); //AppSettings.StorageDBPath() is path of the database
public class StorageDBcontext : DbContext
{
public StorageDBcontext() :
base(new SQLiteConnection()
{
ConnectionString = new SQLiteConnectionStringBuilder() { DataSource = AppSettings.StorageDBPath(), ForeignKeys = true }.ConnectionString
}, true)
{
Database.Connection.Open();
Database.Connection.Close();
}
}
I also tried to delete the database using this function, but I also got an exception: System.Data.Entity.Core.ProviderIncompatibleException: "DeleteDatabase is not supported by the provider."
var context= new StorageDBcontext();
context.Database.Delete();