Question

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. And installed the Setups for 64-bit Windows (.NET Framework 4.5) as well.

Problems


  1. It gives me and exception when i'm trying to create database using code first.

    SQL logic error or missing database no such table: ****

  2. Cannot create Entity Data Model using existing database. No provider is there to create connection. So Cannot Use Model First

  3. Cannot Create data connection. There is no SQLITE provider. Cannot Use DB First within visual studio

Success Scenario


  1. I can create SQLITE database manually(outside visual studio) and connect to the database and read/write/delete data using Entity Framework/ Manual coding.

Is there any way to overcome above problems.

Was it helpful?

Solution

Entity framework 6 for SQLITE is not supporting Database/ Table creation when you use code first.

You need to create database manually and create tables using ExecuteSqlCommand

SQLiteConnection.CreateFile(filePath);
Database.ExecuteSqlCommand(SqLiteQueries.CreateEnterpriseApplicationsTable);

OR as mentioned in the question Success Scenario, it support the code first with existing database.

OTHER TIPS

I believe there is.

  • Target .NET Framework 4.0 from project properties.
  • Change what is in your App.config file with this (After the line that declares xml version);

<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)

-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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top