views:

397

answers:

1

I am able to generate and export the schema creation script from Fluent Nhibernate. Sometime I would like to just modify some fields or add new ones to a table after the schema creation without deleting all the tables. What I do now is that I generate the first schema script and then manually add or modify the fields to the db during the development process.

  • It is possible to generate with Fluent Nhibernate Schema Export statements with ALTER TABLE instead CREATE TABLE?
A: 

Sure is possible

new SchemaUpdate(config).Execute(true, true);
mhenrixon
Where can you set the option to save the exported sql to file? SchemaExport has a SetOutputFile method, but SchemaUpdate doesn't appear to.
Mike
The actual schema is outputted to the console and if you want it to look a bit nicer I recommend using nhibernate profiler ( http://nhprof.com/download ) when updating the schema it logs the whole darn thing nicely. It also logs any errors detected during schema update.
mhenrixon
The first parameter of Execute is for generating the script though I don't know how to actually save it to anywhere. The second parameter is for executing the update.
mhenrixon

related questions