user1765862
user1765862

Reputation: 14145

Scripting SQLite database creation

I'm generating Schema.sql file and I want programatically to create sqllite db file and execute all sql statements from file.

thanks

Upvotes: 0

Views: 747

Answers (1)

mathieu
mathieu

Reputation: 31202

You can use the SchemaExport class to generate the scripts, and/or apply them to the database : http://nhibernate.info/doc/tutorials/first-nh-app/your-first-nhibernate-based-application.html

public class GenerateSchema_Fixture
{
    [Test]
    public void Can_generate_schema()
    {
        var cfg = new Configuration();
        cfg.Configure();
        cfg.AddAssembly(typeof (Product).Assembly);

        new SchemaExport(cfg).Execute(true /*script*/, true /*export to db*/,
                 false /*just drop*/, true /*format schema*/);
    }
}

Upvotes: 1

Related Questions