NHibernate does not create Tables

こ雲淡風輕ζ 提交于 2019-12-08 08:37:29

问题


var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof(<ClassName>).Assembly);
new SchemaExport(cfg).Execute(false, true, false, false);

The above piece of code is supposed to create a database Table with name <ClassName>.

But it is not creating.


回答1:


Your most likely problems:

  • using SQLite with connection.release_mode=on_close
  • no mapping files in the specified assembly
  • mapping files have not been added to the assembly as an Embedded Resource
  • mapping files are not named *.hbm.xml
  • some table or column names should be quoted for SQL (this would be throwing an exception)



回答2:


The first parameter to Execute() must be true.

new SchemaExport(cfg).Execute(**true**, true, false, false);

I don't know why, but there you have it.



来源:https://stackoverflow.com/questions/2311006/nhibernate-does-not-create-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!