如何使实体框架CTP5使用SQLite工作? [英] How to make Entity Framework CTP5 work with SQLite?

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

问题描述

我有使用SQLite的数据库与EF CTP5一个非常困难的时期。我只是想执行这个<一href="http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-$c$c-first-walkthrough.aspx?wa=wsignin1.0">MSDN例如中使用SQLite。但在该行

  VAR食品= db.Categories.Find(食物);
 

我得到一个运行时异常 - System.Data.SQLite.SQLiteException(0X80004005):SQLite的errorno如表所示:分类

我不知道如何解决这个问题。请帮我。

注:app.config文件已被修改,如下所示:

的App.config

 &lt;结构&GT;
  &LT;启动useLegacyV2RuntimeActivati​​onPolicy =真正的&GT;
    &LT; supportedRuntime版本=V4.0/&GT;
  &LT; /启动&GT;
  &LT;运行&GT;
    &LT; generatePublisherEvidence启用=FALSE/&GT;
  &LT; /运行&GT;
  &LT; System.Data这&GT;
    &LT; D​​bProviderFactories&GT;
      &LT;清除不变=System.Data.SQLite/&GT;
      &LT;添加名称=SQLite的数据提供程序不变=System.Data.SQLite
           说明=.NET Framework数据提供的SQLite
           TYPE =System.Data.SQLite.SQLiteFactory,System.Data.SQLite,版本= 1.0.66.0,文化=中性公钥= db937bc2d44ff139/&GT;
    &LT; / DbProviderFactories&GT;
  &LT; /system.data>
  &LT;的ConnectionStrings&GT;
    &LT;添加名称=ProductContext的connectionString =数据源= D:\ codeFirst.db;版本= 3;新= TRUE;的providerName =System.Data.SQLite/&GT;
  &LT; /的ConnectionStrings&GT;
&LT; /结构&gt;
 

解决方案

在我看来,目前的SQLite.net不支持实体框架CTP5 code第一。将不得不等待这样的事情发生。

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

I have no idea how to resolve this issue. Please help me out.

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.

这篇关于如何使实体框架CTP5使用SQLite工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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