1
var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof(<ClassName>).Assembly);
new SchemaExport(cfg).Execute(false, true, false, false);

The above piece of code is supposed to create a database Table with name <ClassName>.

But it is not creating.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    For starters, have you looked into your config? Are the class mapping that you expect included? – flq Feb 22 '10 at 13:14

2 Answers2

7

Your most likely problems:

  • using SQLite with connection.release_mode=on_close
  • no mapping files in the specified assembly
  • mapping files have not been added to the assembly as an Embedded Resource
  • mapping files are not named *.hbm.xml
  • some table or column names should be quoted for SQL (this would be throwing an exception)
Lachlan Roche
  • 25,678
  • 5
  • 79
  • 77
0

The first parameter to Execute() must be true.

new SchemaExport(cfg).Execute(**true**, true, false, false);

I don't know why, but there you have it.

Jorge Alves
  • 1,148
  • 6
  • 13