How to make Entity Framework CTP5 work with SQLite?

It is very difficult for me to use SQLite db with EF CTP5. I was just trying to run this MSDN example using SQLite. But on the line

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

I get an exception at runtime:

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

Note. The app.config file must be modified and looks like this:

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>
+5
source share
4 answers

It seems to me that the current SQLite.net does not support Entity Framework CTP5 code. We'll have to wait for this to happen.

+4
source

System.Data.SQLite CreateDatabase() DeleteDataase() . , .
, CTP 5, CTP 5 dotConnect SQLite. < > . CTP 5 . , , , CTP 5.

+3

Database.SetInitializer<MyDataContext>(null);

works for me. First I use code EF5withSqlite

0
source

All Articles