Is there any C# .NET ORM that can create databases ?
It should be capable of creating MS + MySQL + PostGre + Oracle databases at least.
And I don't mean tables or schemas, I mean the database only.
I use nHibernate, but it can only create tables and schemas, and query/insert but not creating the database itself.

- 78,642
- 66
- 377
- 442
-
Uh, generally no, the ORM goes the *other* way. Are you looking for some sort of Visual database designer? – Noon Silk Jan 08 '10 at 04:42
-
2No, I'm looking for a tool that can create the database right at the customer, without me having to go there and without the customer having to know anything about DBs... Preferably so that I just have to ask the database type, and a username + pw in the setup project, then create the db setup file automatically. And I don't mean Visual Database Designer + RemoteDesktop + a lot of my time – Stefan Steiger Jan 08 '10 at 04:46
-
2It doesn't sound like you want an ORM at all; you just want a cross-platform database creator utility, which may or may not be part of an ORM package. It's an important point, because it would be pretty silly for the database-creation part to dictate how you get objects from the database – Jan 08 '10 at 07:13
-
Since ORM is aware about mapping & schema, it is actually capable of handling this, although yes, this isn't what "ORM" implies. But there are ORM tools that are capable of this; moreover, some of them can even upgrade the schema. – Alex Yakunin Jan 08 '10 at 10:14
-
Concerning database creation: some tools create the schema, but I haven't seen the one capable of creation the database so far... – Alex Yakunin Jan 08 '10 at 10:18
4 Answers
That's usually a little bit outside the scope of an ORM. There's a significant amount of complexity associated with creating a database that often has little to do with your application-specific mappings (permissions, access control, etc.). Sometimes ORM tools will generate the DDL/statements you need to create the database from scratch, but that's not quite the same thing as actually making the database itself.

- 303,634
- 46
- 339
- 357
-
Unfortunately, you seem to be the only person to grasp the question, and I'm getting despaired since it seems there really is no such tool, not even at a price. – Stefan Steiger Jan 08 '10 at 05:36
DataObjects.Net - it is designed for model-first approach; it supports MS SQL, Oracle and PostgreSQL. MySQL support is planned.
See Database Schema Upgrade chapter of the Manual - it explains the details related to runtime schema creation and upgrade.
In contrast to Signum framework (that actually very close by the approach it supports), DataObjects.Net has almost no limitations related to mapping. E.g. you can use composite primary\foreign keys. Its another advantage is perfect LINQ support.
P.S. I'm one of its authors.

- 6,330
- 3
- 33
- 52
-
I just noticed you want the database itself to be created as well. DataObjects.Net currently isn't capable of this, but I immediately found this feature request in our issue tracker: http://code.google.com/p/dataobjectsdotnet/issues/detail?id=509 - so quite likely, this will be done some day. – Alex Yakunin Jan 08 '10 at 10:20
-
Btw, database creation is really a little bit tricky - that's why people avoid this. E.g. it's necessary to specify where (at which storages, etc.) to place the database files, set options like default collation & encoding, etc. - most of these options are specific to a particular RDBMS, so vendors avoid solving this problem in unified fashion. Normally the application deals with just one (selected) RDBMS, and it's easy to implement the database creation for it without involvement of ORM - that's one more reason for vendors to avoid this. – Alex Yakunin Jan 08 '10 at 10:31
-
So actually, if you're choosing ORM, I recommend you to pay more attention on other features. This problem (database creation) actually requires just about a day to be solved by your own. But other ORM features will be used for many weeks... – Alex Yakunin Jan 08 '10 at 10:39
-
Well, then it seems like nhibernate just got one more developer ;-)) – Stefan Steiger Jan 08 '10 at 17:00
http://www.signumframework.com/
One of very few ORM based on Model-first approach.
(source: signumframework.com)
Also note that future releases of Entity framework are supposed to support model-first approach.

- 21,988
- 13
- 81
- 109

- 42,787
- 22
- 113
- 137
-
Well, I'll pass the swearings and offenses for promoting your useless product here apart from editing the sense of my question, and say that I highly doubt that I would need an ORM wrapper if I would only want MS-SQL 2005 & 2008 support... – Stefan Steiger Jan 08 '10 at 05:32
-
Hey I'm not the creator or promoter of signum. I don't mind you giving me a negative vote on my answer but this should not affect the reputation of signum or its creators. If I'd be the signum guy why would I include Entity Framework in my answer. – this. __curious_geek Jan 08 '10 at 12:26
-
Well, not sure. I'm not the one who gave you a negative vote though, since it's remotely related to my question. – Stefan Steiger Jan 08 '10 at 16:46
I've used nHibernate's (NHibernate.Tool.hbm2ddl) SchemaExport feature to generate DDL from my classes and mapping.
Check these out:
Create DB from Classes and Mappings with NHibernate-Domain Driven Design
NH Toolset Guide
A related SO Post:
NHibernate SchemaExport and Configure() catch-22
Update:
After reading your comment, I'm not quite sure this is what you need. Anyway, just for info.
-
I suspect schema export can do what he wants. See http://wiki.fluentnhibernate.org/Schema_generation – Hamish Smith Jan 08 '10 at 05:07
-
Yes, creation works there, but only for SQlite. When I replaced with MS-SQL, it didn't work. – Stefan Steiger Jan 08 '10 at 05:20
-
Yes this is not what I need. Besides, I highly doubt that with system.data.sqlclient.sqlconnection you can connect to anything else but a MS-SQL server... – Stefan Steiger Jan 08 '10 at 05:24
-
I got mine working with mySql though. The db connector can be configured for various db engines/servers though i have not tried it with ms sql. – o.k.w Jan 08 '10 at 06:56
-
What you are proposing is writing a connector for every database. That's beside the point. Looks like my application won't be zero conf after all... – Stefan Steiger Jan 08 '10 at 16:42
-
Not writing, but configuring. Yes, your app probably won't be zero-config. – o.k.w Jan 08 '10 at 18:42