5

I am having a very hard time in using the SQLite db with EF CTP5. I was just trying to execute this MSDN example with SQLite. But at the line

var food = db.Categories.Find("FOOD");

I am getting a runtime exception:

System.Data.SQLite.SQLiteException (0x80004005): SQLite errorno such table: Categories

Note: The app.config file has to be modified and is as follows:

App.config

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
  <runtime>
    <generatePublisherEvidence enabled="false" />
  </runtime>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite"
           description=".Net Framework Data Provider for SQLite"
           type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="ProductContext" connectionString="Data Source=D:\CodeFirst.db;Version=3;New=True;" providerName="System.Data.SQLite" />
  </connectionStrings>
</configuration>
halfer
  • 19,824
  • 17
  • 99
  • 186
Anindya Chatterjee
  • 5,824
  • 13
  • 58
  • 82

4 Answers4

4

It seems to me that current SQLite.net does not support Entity Framework CTP5 code first. Will have to wait for that to happen.

Anindya Chatterjee
  • 5,824
  • 13
  • 58
  • 82
3

System.Data.SQLite does not provide CreateDatabase() and DeleteDataase() dynamic database creation at the moment. At least, this forum post is unanswered for approximately a month.
We already offer both dynamic database creation and CTP 5 support, and plan to blog about CTP 5 support in dotConnect for SQLite soon.
UPDATE. The CTP 5 article is available. It contains some notes concerning database creation peculiarities, and a sample illustrating CTP 5 usage.

Devart
  • 119,203
  • 23
  • 166
  • 186
  • Devart - eagerly awaiting the blog post. I can find NO information about dotconnect for sqlite with code first ctp5. None! I have even posted in the Devart forum and sent an email from the Devart website. –  Mar 01 '11 at 22:32
  • @user327325, we have released the article. See the update to the answer. – Devart Mar 02 '11 at 13:40
0

Adding

Database.SetInitializer<MyDataContext>(null);

works for me. I use EF5 code first with Sqlite

Arsen Mkrtchyan
  • 49,896
  • 32
  • 148
  • 184
0

you can see this:

http://www.devart.com/blogs/dotconnect/index.php/entity-framework-code-first-support-for-oracle-mysql-postgresql-and-sqlite.html

Omidam81
  • 1,887
  • 12
  • 20
  • Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Jack Nov 14 '12 at 14:21