mardi 3 mai 2016

Entity Framework 6 with SQLite

I try to run SQLite with EF but it's not working. I used this walktrough SQLite with EF

This is my Visual Studio project folder containing the Database.sqlite file and Context.cs class:

/bin
/obj
/Properties
/...
App.config
...
Database.sqlite
Context.cs

This is the App.config file:

<?xml version="1.0" encoding="utf-8"?>
...
  <connectionStrings>
    <add name="Context" connectionString="Data Source=|DataDirectory|Database.sqlite" providerName="System.Data.SQLite.EF6" />
  </connectionStrings>
  ...
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
    </DbProviderFactories>
  </system.data>
</configuration>

And I allways get the same error:

An unhandled exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll

Additional information: An error occurred while updating the entries. See the inner exception for details.

Inner Exception is:

{"SQL logic error or missing database\r\nno such table: Table"}

The table "Table" is there.

Aucun commentaire:

Enregistrer un commentaire