[英]Work with SQLITE database using visual studio 2013
I'm Trying to work with SQLITE database using visual studio 2013. I have installed System.Data.SQLite (x86/x64) 1.0.92 to visual studio. 我正在尝试使用Visual Studio 2013使用SQLITE数据库。我已经在Visual Studio中安装了System.Data.SQLite(x86 / x64)1.0.92 。 And installed the Setups for 64-bit Windows (.NET Framework 4.5) as well.
并安装了用于64位Windows(.NET Framework 4.5)的安装程序。
Problems 问题
It gives me and exception when i'm trying to create database using code first. 当我尝试首先使用代码创建数据库时,它给了我一个例外。
SQL logic error or missing database no such table: ****
SQL逻辑错误或缺少数据库,无此表:****
Cannot create Entity Data Model using existing database. 无法使用现有数据库创建实体数据模型。 No provider is there to create connection.
没有提供者可以创建连接。 So Cannot Use Model First
所以不能先使用模型
Success Scenario 成功案例
Is there any way to overcome above problems. 有什么办法可以克服以上问题。
Entity framework 6 for SQLITE is not supporting Database/ Table creation when you use code first. 首次使用代码时,用于SQLITE的实体框架6不支持数据库/表的创建。
You need to create database manually and create tables using ExecuteSqlCommand
您需要手动创建数据库并使用
ExecuteSqlCommand
创建表
SQLiteConnection.CreateFile(filePath);
Database.ExecuteSqlCommand(SqLiteQueries.CreateEnterpriseApplicationsTable);
OR as mentioned in the question Success Scenario, it support the code first with existing database. 或如问题“成功方案”中所述,它首先支持现有数据库的代码。
I believe there is. 我相信有。
< configuration
> < startup useLegacyV2RuntimeActivationPolicy ="true"
> < suppurtedRuntime
version="v4.0"/> < /
startup> < /configuration
> (I couldn't insert the XAML code here correctly so check before copying or type it manually) <
configuration
> < startup useLegacyV2RuntimeActivationPolicy ="true"
> < suppurtedRuntime
版本=“ v4.0” /> < /
启动> < /configuration
>(我无法在此处正确插入XAML代码,因此请在复制或手动键入之前进行检查)
-In case there is a problem with your connection string use; -如果您的连接字符串使用有问题;
public static string ConnectionString = @"Data Source = databasename.db;Version=3; "
The last thing means that I suggest you to use SQLite3. 最后一件事意味着我建议您使用SQLite3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.