views:

100

answers:

1

Here is my configuration:

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

BuildSchema looks like this:

private static void BuildSchema(Configuration config)
{
    new SchemaExport(config).Create(false, true);
}

Luckily this works great and creates a file named foo.db to which I can read and write. Unluckily, every time i run this code, foo.db is overwritten. How can I configure (Fluent)NHibernate to create the file only if it doesn't already exist?

+3  A: 

Put an if statement in your BuildSchema?

if (!File.Exists("foo.db"))
  new SchemaExport(config).Create(false, true);
James Gregory