kagundajm
kagundajm

Reputation: 1210

Why is Nhibernate SchemaExport unable to create a PostgreSQL database?

I have the following code to generate the schema for a database in Nhibernate

new SchemaExport(configuration).Execute(true, true, false);

but when run against a PostgreSQL database, I end up getting the following error

[NpgsqlException (0x80004005): FATAL: 3D000: database "dbname" does not exist] 

If I however create the database manually, the schema is exported without errors. An so the question: Why is Nhibernate SchemaExport unable to create a PostgreSQL database and yet this works against other databases like SQLite, MsSqlCe and MsSql Server.

I have searched for online literature but have been unable to locate any highlighting on this issue.

I am using Nhibernate 3.3.1 with PostgreSQL 9.2.

Upvotes: 0

Views: 576

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324861

You must create the database before you can create the tables and other objects within the database.

Do this with a CREATE DATABASE statement on a PostgreSQL connection - either in your app, or via psql or PgAdmin-III.

PostgreSQL doesn't support creating databases on demand / first access. Perhaps that's what your tool is expecting?

If you think the DB does exist and you can see it in other tools, maybe you're not connecting to the same database server? Check the server address and port.

Upvotes: 2

Related Questions