nhibernatefluent-nhibernatenhibernate-mappingautomappingschemaexport

Fluent NHibernate AutoMapping SchemaExport - Change object model and Keeping Data


Is there a way for the fluent automapping to alter a schema when the data object model changes (adding a new property to a class), currently it only drops and recreates the database schema, which would lose all the data in the database. Can it use Alter table instead of drop / create table, or am I just dreaming?

Can fluent update the database schema according to automapping without losing data?

Cheers,


Solution

  • Doh!

    Just use

    new SchemaUpdate(config).Execute(false, true); 
    

    instead of

    new SchemaCreate(config).Execute(yadda yadda);