When working with NHibernate, should you create your database tables before your map files?

You need the mapping files for SchemaExport.

Up vote 1 down vote favorite share g+ share fb share tw.

Simple question, hopefully with a simple answer. I was under the impression I should create my tables and then use the map files to map my POCO classes to the database objects. After following some tutorials, I have this code in my Test SetUp: new SchemaExport(_configuration).

Execute(false, true, false, false); Which, obviously, create the table structure as defined in the mappings, so I'm confused. Nhibernate nhibernate-mapping link|improve this question asked Aug 20 '09 at 21:12scottm8,6562160 99% accept rate.

You need the mapping files for SchemaExport. Ideally you write / design your classes first, write the mapping files afterwards. When writing mapping files, you are designing the database tables at the same time.

SchemaExport just creates the schema from the mapping files where all the information is usually available. SchemaExport is highly recommendable, even if it is a bit "hidden" in the docs.

Sometimes you write new code for existing database, so you have to create (or have) database first, then need to prepare mappings manually. EDIT: I am using Fluent NHibernate, so this can be done fully automatically, not sure in different environments.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions