简体   繁体   中英

How to create a db3 database with Sqlite-Net

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>();
        }
    }
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM