Sim*_*mon 41 c# sqlite entity-framework entity-framework-6
我知道在这个主题上已经有几个类似的问题了,但是其中很多都来自SQLite的旧版本,据我所知,它并没有完全支持EF 6.我已经尝试过这些线程的无数建议,要么是做错了,要么是必须改变的.
我正在使用VS 2013,面向.NET 4.5.1,并已从system.data.sqlite.org下载页面安装了sqlite-netFx451-setup-bundle-x86-2013-1.0.96.0.exe软件包,以及来自NuGet Manager的System.Data.SQLite EF6包(安装EF6).
下面是我当前的App.config文件(除了我尝试将Version,Culture和Public键变量添加到类型中之外,它几乎没有变化):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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.1" />
</startup>
<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, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<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, Version=1.0.96.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139"
/>
</DbProviderFactories>
</system.data>
</configuration>
Run Code Online (Sandbox Code Playgroud)
而我的packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.2" targetFramework="net451" />
<package id="System.Data.SQLite.EF6" version="1.0.96.0" targetFramework="net451" />
</packages>
Run Code Online (Sandbox Code Playgroud)
如果我执行某些操作,例如尝试从模型I生成数据库,请看以下错误:
没有为ADO.NET提供程序找到具有不变名称"System.Data.SQLite.EF6"的实体框架提供程序.确保提供商已在"entityFramework"部分注册...
我已经尝试弄乱App.config文件并添加其他提供商和提供商,如旧线程建议但无济于事.
我该如何解决这个问题?任何帮助是极大的赞赏!
编辑:我设法让它运行良好,使用数据库第一种方法.以下是我的App.config文件的相关部分:
<providers>
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
<DbProviderFactories>
<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" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
Run Code Online (Sandbox Code Playgroud)
我正在使用EF 6.1.2和System.Data.SQLite 1.0.96.0.
Ami*_*neh 87
我在App.config中添加了一行就解决了同样的错误
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
Run Code Online (Sandbox Code Playgroud)
PS:添加provider到<configuration>> <entityFramework>><providers>
Pau*_*aul 11
这是一个有效的app.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<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.2" />
</startup>
<entityFramework>
<providers>
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
</providers>
</entityFramework>
<connectionStrings>
<!-- use AppDomain.SetData to set the DataDirectory -->
<add name="MapDbConnectionStr" connectionString="Data Source=|DataDirectory|MapDb.sqlite" providerName="System.Data.SQLite" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
Run Code Online (Sandbox Code Playgroud)
小智 5
我终于得到了它的工作
我正在使用:EF 6.1.3 http://www.microsoft.com/en-us/download/details.aspx?id=40762 和System.Data.SQLite 1.0.96.0 sqlite-netFx451-setup-bundle-x86 -2013-1.0.96.0.exe
我按照写的描述: 数据库首先使用system.data.sqlite 1.0.93创建实体框架6.1.1模型 (在此描述中安装了实体框架的nuget包-i也做了)
对于app.config文件,我使用了以下修复程序:https: //stackoverflow.com/a/24324212/885349(由tomexou编写)
最后,ADO.Net实体数据模型映射器中未显示SQLite Connector
缺少的链接是\ bin文件夹.我必须为以下dll设置"Copy Local"= true设置:
仅为了完整性 - 通过Nuget和\ bin文件夹添加
并显示了SQLite连接......
| 归档时间: |
|
| 查看次数: |
31913 次 |
| 最近记录: |