如何使Entity Framework CTP5与SQLite配合使用? [英] How to make Entity Framework CTP5 work with SQLite?

查看:137
本文介绍了如何使Entity Framework CTP5与SQLite配合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难在使用SQLite数据库与EF CTP5。我只是试图执行这个 MSDN示例与SQLite。但在线上

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

我收到运行时异常:


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


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



App.config

 < configuration> 
< startup useLegacyV2RuntimeActivationPolicy =true>
< supportedRuntime version =v4.0/>
< / startup>
<运行时>
< generatePublisherEvidence enabled =false/>
< / runtime>
< system.data>
< DbProviderFactories>
< remove invariant =System.Data.SQLite/>
< add name =SQLite数据提供者invariant =System.Data.SQLite
description =。SQLite的Net Framework数据提供者
type =System.Data.SQLite .SQLiteFactory,System.Data.SQLite,Version = 1.0.66.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139/>
< / DbProviderFactories>
< /system.data>
< connectionStrings>
< add name =ProductContextconnectionString =Data Source = D:\CodeFirst.db; Version = 3; New = True; providerName =System.Data.SQLite/>
< / connectionStrings>
< / configuration>


解决方案

在我看来,目前的SQLite.net不首先支持实体框架CTP5代码。将不得不等待这种情况发生。


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>

解决方案

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

这篇关于如何使Entity Framework CTP5与SQLite配合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆