Sqlite Database Creation
Hi,
I'm new at using Fluent Hibernate and databases. So to get familiar with working with databases I started a learning project of mine to learn to work with them.
So far I'm at the point where I have mappings setup, not using the Automapping functionality. I have unit tests working, using an in memory sqlite database. I'm at the point where I tried to create the objects and save them to the database, but then I soon realized I needed a database to save it to.
So my main question is how can I create a new sqlite3 database file from my fluent nhibernate mappings at runtime? Is that possible or am I misunderstanding something?
Thanks
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Paul Batum on 31 Mar, 2010 03:33 AM
If you want to move from using an in memory db to a file based db, its pretty straightforward. You want:
See: http://wiki.fluentnhibernate.org/Database_configuration
3 Posted by arkhan4 on 31 Mar, 2010 12:50 PM
I did try that, but I don't have the database file created yet? Are you saying it will create it for me automatically if not there?
I tried using ExportSchema, but I don't understand what it's going to export, a new database file with tables based on my mappings or sqlite sql instructions to create the tables based on the mappings?
Here's the code I have so far related to creating a SessionFactory:
private static ISessionFactory m_sessionFactory;
Support Staff 4 Posted by Paul Batum on 25 Apr, 2010 02:00 PM
Sorry, somehow I lost track of this conversation. You've probably already resolved this but in case you're still stuck...
I forget exactly what the parameters are for the Create method on SchemaExport, but my little test FNH project that I use to diagnose issues passes (true, true).
See here:
http://github.com/paulbatum/Fluent-NH-Test-Bed/blob/master/Console/...
You can download the entire test project from github if you need a working example:
http://github.com/paulbatum/Fluent-NH-Test-Bed/archives/master
Paul Batum closed this discussion on 16 May, 2010 06:51 AM.