Reputation: 5043
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.
Upvotes: 0
Views: 2580
Reputation: 53
Create an Action and Pass it to the SchemaUpdate method
string script = "LogFile.txt"
if (!File.Exists(script))
File.Create(script);
// writes out an alter table script
Action<string> updateLogFile= x =>
{
//Open up file, append
using (var file = new FileStream(script, FileMode.Append))
{
//Write each line
using (var sw = new StreamWriter(file))
{
sw.Write(x);
sw.Close();
}
}
};
// Perform Schema update into updateLogFile Action
new SchemaUpdate(config)
.Execute(updateLogFile, true);
Upvotes: 0