Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 759
Fluent Newbie Avatar asked Jan 23 '26 09:01

Fluent Newbie


1 Answers

Doh!

Just use

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

instead of

new SchemaCreate(config).Execute(yadda yadda);
like image 148
Fluent Newbie Avatar answered Jan 27 '26 00:01

Fluent Newbie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!