Linux 将NHibernate生成的所有sql导出到文本文件中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3677188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Export all sql generated by NHibernate to a text file
提问by Byron Sommardahl
I have a console app that exports my entity models to my sql db and I am able to export that schema to an .sql file without issue. However, my DBA's want .sql files for all the initial data that should be populated in the db as well. My console app uses NHibernate to save a bunch of objects to the database right after it creates the database (Fluent NHibernate's .CreateDatabase()
). But, now, I need to find a way to export all the inserts/updates that happen after creation. Looking around on google for a few minutes didn't turn up much. Any help would be appreciated.
我有一个控制台应用程序,可以将我的实体模型导出到我的 sql db,并且我能够将该架构导出到 .sql 文件而不会出现问题。但是,我的 DBA 需要 .sql 文件来存储所有应该填充到数据库中的初始数据。我的控制台应用程序使用 NHibernate 在创建数据库后立即将一堆对象保存到数据库中(Fluent NHibernate's .CreateDatabase()
)。但是,现在,我需要找到一种方法来导出创建后发生的所有插入/更新。在谷歌上环顾几分钟并没有出现太多。任何帮助,将不胜感激。
采纳答案by Aliostad
You can enable tracing using
您可以使用启用跟踪
<property name="show_sql">true</property>
Then you can use .NET configuration to save your tracing to a file or just see it in DebugView and save it to a file in there.
然后您可以使用 .NET 配置将您的跟踪保存到一个文件中,或者只是在 DebugView 中查看它并将其保存到一个文件中。
Have a look in here:
看看这里:
回答by Aaron Fischer
I don't know if I would deal with it like this. you can try a tool like red-gates SQL Packagerit will generate both schema and the data scripts from your database.
我不知道我是否会这样处理。您可以尝试使用 red-gates SQL Packager这样的工具,它会从您的数据库生成模式和数据脚本。