How to create a db3 database with Sqlite-Net

2019-09-07 11:41发布

问题:

In a mono project I want to create a database and use that, and Sqlite-Net is optimzied for mono so would go with that. But I cant find any documentation how to create a database with it. So I just try to connect to it and hope it will say "Database dont exists, I will create one" but I get an exception so that approch dont work

readonly string _pathToDatabase = "Meter_db.db3";
public InstallMeterRepository()
{
    if(!File.Exists(_pathToDatabase))
    {                
        using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
        {                   
            conn.CreateTable<InstalledMeter>();
        }
    }
}

回答1:

If you want to create a new database, you need the driver: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

You can check here too: http:// sqlite.phxsoftware.com/

And with this FREEWARE manager, you can do whatever you want with your database: (Recomended!) SQLite2009 Pro Enterprise Manager http://osenxpsuite.net/?xp=3&uid=managementtools

Happy develop!

Fear