简体   繁体   English

如何使用Sqlite-Net创建db3数据库

[英]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. 在一个单声道项目中,我想创建一个数据库并使用它,并且Sqlite-Net被优化为单声道,所以就这样。 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 所以我只是尝试连接到它并希望它会说“数据库不存在,我将创建一个”但我得到一个例外,以便approch不工作

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 如果要创建新数据库,则需要驱动程序: http//system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

You can check here too: http:// sqlite.phxsoftware.com/ 你也可以在这里查看: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 有了这个FREEWARE经理,你可以用你的数据库做任何你想做的事情:(推荐!)SQLite2009 Pro企业管理器http://osenxpsuite.net/?xp=3&uid=managementtools

Happy develop! 快乐发展!

Fear 恐惧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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