tags:

views:

1488

answers:

1

I'm very new at this, but I need to create new tables from existing classes without creating them by hand. Can this be done using a tool or command line?

+4  A: 

Yes, with nhibernate you can generate and update schemas automatically.

var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly(typeof (aClassFromYourProject).Assembly);
new SchemaExport(cfg).Execute(false, true, false, false);

http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/01/your-first-nhibernate-based-application.aspx

http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/28/create-and-update-database-schema.aspx

Daniel Auger
Thank you very much! I recently chose Linq-to-Sql for a company project and wish I'd gone with Nhibernate instead, given its completeness, community support and capabilities. I appreciate the help! It worked perfectly.
mkelley33
Thank you for the answer. I've recently had the same question and I've immediately found a short and usable answer.
Lyubomyr Shaydariv