O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating database schema creation scripts

The nice thing about the model first approach is that we can instruct NHibernate to automatically generate the creation scripts for the database schema for us. That is, we do not have to manually create the database schema, just let NHibernate figure out how the tables and their relations are going to look. To do its job, NHibernate uses the information we provide when defining the mappings for our domain model.

For this job, NHibernate provides us with a class called SchemaExport, which expects a Configuration object as the parameter of its constructor.

var configuration = ...
var exporter = new SchemaExport(configuration);

We can then call the Execute method, which has several overloads. These overloads ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required