I want to use DDD in a new project and model my classes first, then generate the database schema based on the class library. My plan is to do this with the NHibernate hbm2ddl tool SchemaExport
.
The problem is that I can't get the SchemaExport
to work because of a weird catch-22 problem it puts me in. The SchemaExport
requires a Configuration
object that itself requires a valid NHibernate configuration file as well as a set of database mappings.
The catch-22 here is that when I do the Configure(), it complains "Could not determine the name of the table for entity 'MyEntity'; remove the 'table' attribute or assign a value to it."
So the Configure()
method requires the table to exist, while the SchemaExport
is supposed to create it based on the Configuration
that I can't create because the table isn't doesn't exist.
So, how on earth am I supposed to create a valid NHibernate Configuration
containing the mappings required for SchemaExport
to actually do something useful without having Configure()
throw and complain that it can't find the tables that are to be created with SchemaExport
? Is there a "mode" I can set the Configuration
object in so it won't check the database for the existence of the given tables, or is there something else I need to do?