Created
July 28, 2011 21:42
-
-
Save johnathan-sewell/1112649 to your computer and use it in GitHub Desktop.
Bare bones NHibernate schema export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using NHibernate; | |
using NHibernate.Cfg; | |
using NHibernate.Tool.hbm2ddl; | |
using lexikon.console.domain; | |
namespace lexikon.console | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var config = new Configuration().Configure(); | |
//export schema - drop and recreate table | |
var schemaExport = new SchemaExport(config); | |
schemaExport.Create(true, true); | |
var sessionFactory = config.BuildSessionFactory(); | |
using (ISession session = sessionFactory.OpenSession()) | |
using (ITransaction transaction = session.BeginTransaction()) | |
{ | |
var word = new Word | |
{ | |
Text = "abracadabra" | |
}; | |
session.Save(word); | |
transaction.Commit(); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment