0
我使用FluentMigrator在C#中使用FluentMigrator.Runner.MigrationRunner創建SqlLite數據庫。我不知道有什麼方法可以在需要創建數據庫時使用SetPassword命令或SqlConnection命令嗎?有一個SqLiteRunnerContextFactory對象,但它似乎不是我可以用來指定密碼的屬性。FluentMigrator創建密碼保護SqlLite DB
public MigrationRunner CreateMigrationRunner(string connectionString, string[] migrationTargets, Assembly assembly, long version)
{
var announcer = new TextWriterAnnouncer(Console.WriteLine) { ShowSql = true };
var options = new ProcessorOptions { PreviewOnly = false, Timeout = 60 };
var runnerContext = new SqLiteRunnerContextFactory().CreateRunnerContext(connectionString, migrationTargets, version, announcer);
var sqlLiteConnection = new SQLiteConnection(connectionString);
//If the DB has already been created, it crashes later on if I specify this
sqlLiteConnection.SetPassword("ban4an4");
return new MigrationRunner(assembly,
runnerContext,
new SQLiteProcessor(sqlLiteConnection,
new SQLiteGenerator(),
announcer,
options,
new SQLiteDbFactory()));
}
我想避免在連接時設置密碼之前查看文件是否存在。