如何使实体框架CTP5与SQLite一起使用?

Ani*_*jee 5 c# sqlite .net-4.0 entity-framework-4 ef-code-first

我在使用带有EF CTP5的SQLite数据库时非常困难.我只是试图用SQLite 执行这个MSDN示例.但是在线

var food = db.Categories.Find("FOOD");
Run Code Online (Sandbox Code Playgroud)

我收到运行时异常:

System.Data.SQLite.SQLiteException(0x80004005):SQLite errorno这样的表:Categories

注意:必须修改app.config文件,如下所示:

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>
Run Code Online (Sandbox Code Playgroud)

Ani*_*jee 4

在我看来,当前的 SQLite.net 首先不支持实体框架 CTP5 代码。必须等待那件事发生。