Book Image

Learning NHibernate 4

Book Image

Learning NHibernate 4

Overview of this book

Table of Contents (18 chapters)
Learning NHibernate 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Generating the database scripts from mappings


In the beginning, we looked at one use of the SchemaExport class where we used it to generate database creation scripts based on mappings declared. In this section, we would delve deeper into this to see what different options SchemaExport offers to generate database creation scripts. We are also going to look at another class named SchemaUpdate that can generate database update scripts by comparing changed mappings and existing database schema.

Note

If you are working on a legacy project with an existing database then you would have little use of the SchemaExport class. Since you have already got a database in place, there is no need to generate a new database creation script. You may want to use SchemaUpdate to generate scripts to manage changes to domain model but exercise caution while doing so. Since the initial version of database is not created through SchemaExport, chances are that SchemaUpdate would not respect the semantics and rules...