Dropping all tables

Is there a way to drop/delete all the tables in a db (MySql in my case) using ormlite and ignoring the constraints?

Thanks.

Not specifically, but you should be able to do it with something like:

var dialect = db.GetDialectProvider();
db.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=0;");
foreach (var table in db.GetTableNames())
{
    db.ExecuteSql("DROP TABLE " + dialect.GetQuotedTableName(table));
}
db.ExecuteNonQuery("SET FOREIGN_KEY_CHECKS=1;");

Excellent. Thank you.

1 Like