0

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

thanks

2
  • So far I was manually created db file with manually imported sql statements and now I want to move further and execute those programatically. So, I need some link examples, some site which point me to the right direction. Commented Jan 11, 2013 at 7:44
  • 1
    maybe this helps, Scripting SQLite database creation, swinbrain.ict.swin.edu.au/wiki/… Commented Jan 11, 2013 at 7:50

1 Answer 1

1

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*/);
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

thanks for the answer but I already have generated Schema.sql, I'm struggle with how to execute those sql from the file into db. Thanks
ok, where should I find created sql db file. My schema.sql is generated inside C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0, but db file is not there. Tried in bin and obj\Debug but again nothing
It will be the SQLite db file specified in nhibernate connection string

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.