Is it possible to generate the database tables and c# classes from NHibernate config files? Afterwards, is it possible to change the config files and update the tables and config files non-destructively?
Do you recommend any tools to do this? (preferably free...)
NHibernate is an actively developed, fully featured, open source object-relational mapper for the . NET framework. It is used in thousands of successful projects. It's built on top of ADO.NET and the current version is NHibernate 4.0.
As mentioned by Joachim, it's the "hbm2ddl.auto" setting that you're looking for.
You can set it by code like this:
var cfg = new NHibernate.Cfg.Configuration();
cfg.SetProperty("hbm2ddl.auto", "create");
cfg.Configure();
And you can also set it in your App.config file:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="hbm2ddl.auto">create</property>
check out the "hbm2ddl.auto" setting (in configuration or NHibernate.Cfg.Configuration ). with "create" you can recreate the whole database schema from your mappings and "update" setting should just update your schema.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With