如何配置FluentNHibernate不覆盖现有的SQLite数据库文件?

ant*_*ony 2 sqlite nhibernate fluent-nhibernate

这是我的配置:

this.factory = Fluently.Configure().
    Database(SQLiteConfiguration.Standard.UsingFile("foo.db").
        ShowSql()).
    Mappings(m => m.FluentMappings.AddFromAssemblyOf<Bar>()).
    ExposeConfiguration(BuildSchema).
    BuildSessionFactory();
Run Code Online (Sandbox Code Playgroud)

BuildSchema看起来像这样:

private static void BuildSchema(Configuration config)
{
    new SchemaExport(config).Create(false, true);
}
Run Code Online (Sandbox Code Playgroud)

幸运的是,这很好用,并创建了一个名为foo.db的文件,我可以读写它.不幸的是,每次运行此代码时,foo.db都会被覆盖.如何配置(Fluent)NHibernate只有在文件尚不存在的情况下才能创建文件?

Jam*_*ory 8

在BuildSchema中添加if语句?

if (!File.Exists("foo.db"))
  new SchemaExport(config).Create(false, true);
Run Code Online (Sandbox Code Playgroud)