We are using Castle ActiveRecord as a helper layer on top of NHibernate. To generate our database, we use:
ActiveRecordStarter.CreateSchema();
To generate the sql for building our database we use:
ActiveRecordStarter.GenerateCreationScripts(filename);
They work like a charm. However we sometimes don’t want to generate a table for every one of our entities. I believe nhibernate has a mechanism for excluding certain tables from a schema build (see here) – does anyone know whether ActiveRecord can do the same thing?
For posterity, here’s what I ended up doing:
1) Grabbed the NHibernate SchemaExporter source code and renamed the class to “OurSchemaExporter”.
2) Added a new constructor:
3) Modified the initialize method to call out to find out whether a script should be included:
4) When using OurSchemaExporter, check whether we want to include certain tables by looking at the contents of each SQL create script:
A hack, but it does the job.