数据库
首页 > 数据库> > CodeGo.net>如何在SQLite和Visual Studio 2013中使用EF

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

作者:互联网

我想将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