ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

CodeGo.net>如何在SQLite和Visual Studio 2013中使用EF

2019-11-21 02:08:56  阅读:241  来源: 互联网

标签:sqlite visual-studio-2013 c entity-framework visual-studio


我想将SQLite与Entity Framework和Visual Studio 2013 Desktop Express结合使用.

为此,我右键单击“参考”并安装(具有选定的依赖项)“ System.Data.SQLite(X86 / x64)”(版本1.0.94.1)NuGet程序包

现在,如果我向项目中添加一个新元素并选择ADO.NET实体数据模型,则看不到SQLite提供程序:我只有Microsoft SQL Server.

我有.NET Framework 4.5.1和Windows 7.

这是我的App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
 </configSections>
 <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
 </startup>
 <system.data>
   <!--
    NOTE: The extra "remove" element below is to prevent the design-time
          support components within EF6 from selecting the legacy ADO.NET
          provider for SQLite (i.e. the one without any EF6 support).  It
          appears to only consider the first ADO.NET provider in the list
          within the resulting "app.config" or "web.config" file.
-->
   <DbProviderFactories>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <remove invariant="System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
   </DbProviderFactories>
 </system.data>
 <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
       <parameters>
           <parameter value="mssqllocaldb" />
       </parameters>
    </defaultConnectionFactory>
    <providers>
        <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
 </entityFramework>
</configuration>

解决方法:

您必须从http://system.data.sqlite.org开始安装DDEX提供程序-但Express版本不允许安装任何扩展,例如DDEX提供程序.

您可以安装新的Visual Studio 2013社区.在此处,转到“工具”,“扩展和更新”,在搜索框中键入“ sqlite ddex”,然后安装它.

标签:sqlite,visual-studio-2013,c,entity-framework,visual-studio
来源: https://codeday.me/bug/20191121/2048397.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有