Make Fluent NHibernate output schema update to file

后端 未结 2 2020
醉梦人生
醉梦人生 2021-02-13 20:21

I am successfully getting Fluent NHibernate to update my database by calling UpdateBaseFiles:

Public Sub UpdateBaseFiles()
    Dim db As SQLiteConfiguration
            


        
2条回答
  •  一向
    一向 (楼主)
    2021-02-13 21:10

    SchemaUpdate calls the action for each update it does so you dont want to be recreating (and therefore overwriting) the same file on each command as above, this is what is required:

    using (var file = new FileStream(@"..\..\..\schema-update.sql",
           FileMode.Create,
           FileAccess.ReadWrite))
    using (var sw = new StreamWriter(file))
    {
       new SchemaUpdate(config)
           .Execute(sw.Write, false);
    }
    

提交回复
热议问题