dgx*_*ard 20 sqlite entity-framework
我有一个项目,我刚刚使用nuget更新.这个更新的实体框架从6.1到6.1.1,它将sqlite更新为1.0.93.我想从我最新的数据库更新我的模型.我做了以下步骤:1)数据库模型2)选择sqlite数据库3)生成
生成后,我收到以下错误消息,如下所示.我安装了1.0.93设计时组件.有谁知道究竟是什么导致了这个错误.项目引用和版本都与上面显示的版本匹配.
错误信息:
您的项目引用了最新的实体框架; 但是,无法为您的数据连接找到与此版本兼容的Entity Framework数据库提供程序.
更新:
我最终使用包管理器控制台手动安装6.1.0
Install-Package EntityFramework -Version 6.1.0
然后在我的csporj文件中替换
包\ EntityFramework.6.1.1
同
包\ EntityFramework.6.1.0
我尝试从数据库和代码优先从数据库创建EF Designer但我仍然得到相同的错误.
UPDATE
我已按照汤姆提供的指示行事,感谢您抽出宝贵时间深度回应,感谢您的光临.但我不能让实体框架设计师使用SQLite 1.0.93.我发现了什么:
1)当我在Tom描述的工具菜单中添加SQLite数据源时,我看到了SQLite数据提供程序.

2)但是当我重新启动visual studio时,数据源没有连接

3)数据源可以刷新,重启后有效

4)添加新数据项但SQLite未列为提供者

我已经仔细检查了注册表,EF6被附加到不变名称,SQLite dll在GAC中注册.我会试着看看还能找到什么但是在这一点上我不知道该找什么.作为旁注,我尝试过dotConnect,但它对EF 6.1.1无效.
更新2
有没有人知道Entity Framework Designer是否有一个日志选项来找出可能发生的事情?
Tom*_*omL 16
[ 更新:有关与Visual Studio 2013 Update 4(Pro和Ultimate)以及最新版本的Sqlite Providers和EF一起使用的更简单的解决方案,请查看下面发布的解决方案'broslav'.不知道它是否适用于Express版本...]
好的,这是一个建议.这不适用于Visual Studio Express版本.此外,我不知道如何使其工作更新现有项目.这是一个绝对痛苦的屁股.我没有测试是否需要一切,但这应该工作:
首先,不要将NuGet包用于SQLite,而是从这里下载程序集安装程序:http: //system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
安装32位Windows(.NET Framework 4.5.1)安装程序的安装程序:sqlite-netFx451-setup-bundle-x86-2013-1.0.93.0.exe(10.00 MiB)(不是64位版本).这是设计师唯一的一个.
安装并选择在GAC中安装并安装Designer for VS13.
对于以下内容,确切的顺序很重要!
我制作了这些步骤的视频,请参阅:http://vimeo.com/103372740
在VS13中创建一个项目.将构建目标明确定位到框架4.5.1和x86.保存并构建.
接下来,从NuGet安装最新的EF 6软件包(6.1.1).保存并构建.
手动添加对已安装的SQLite程序集(包括Designer)的引用,在Assemblies下的Reference Manager下,您可以找到Extensions选项,用于在GAC中选择四个添加的程序集:System.Data.SQLite Core + Designer + for Entity Framework + for LINQ ..保存并构建.
然后通过"工具"下的"连接到数据库"创建与数据库的连接.在您执行任何其他操作之前保存并生成然后重新启动 Visual Studio.在启动ADO.NET实体数据模型向导之前,请不要执行任何操作,因此请勿刷新数据库连接.
添加ADO.NET实体数据模型,选择"从数据库生成".您的数据库连接将显示在下拉列表中.保持不变,但无论如何选择创建一个新连接并再次选择完全相同的数据库(就像您正在创建一个新连接).听起来很傻,但这很重要,请看下面的图片......

当我实际上以这种方式添加ADO.NET实体数据模型时它确实呈现了令人讨厌的错误,但是Next按钮是可选择的,一切都有效(令人惊讶)!
设计师工作,检索数据和编写数据工作.
还没有测试在另一台机器上的部署...我正在使用Win7 64位.
更改更新:要获得正确配置以实际访问数据库,您必须在完成上述所有操作后从NuGet安装System.Data.SQLite.EF6包,然后添加
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
到App.Config并删除其他提供程序并删除介于两者之间的一切<system.data></system.data>,否则你会得到一些例外.但请注意,这意味着每次要更新EDMX模型时,都必须将App.Config invariantName ="System.Data.SQLite"更改为invariantName ="System.Data.SQLite.EF6",反之亦然.
**这变得荒谬了吗?是的!它给了我很头疼......**
bro*_*lav 11
这对我有用:
add和remove项目内DbProviderFactories标签在App.config所以我的包裹是:
<packages>
<package id="EntityFramework" version="6.1.1" targetFramework="net451" />
<package id="System.Data.SQLite" version="1.0.94.1" targetFramework="net451" />
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net451" />
<package id="System.Data.SQLite.EF6" version="1.0.94.0" targetFramework="net451" />
<package id="System.Data.SQLite.Linq" version="1.0.94.1" targetFramework="net451" />
</packages>
Run Code Online (Sandbox Code Playgroud)
和我一起工作的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>
<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>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog" />
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter" />
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</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>
<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" />
<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>
<connectionStrings>
<add name="WorkinDataEntities" connectionString="metadata=res://*/WorkinDataModel.csdl|res://*/WorkinDataModel.ssdl|res://*/WorkinDataModel.msl;provider=System.Data.SQLite.EF6;provider connection string="data source=X:\dev\proj\workin\bin\data.db"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,最终,对我来说,没有必要从invariantName删除或重新排列其他提供程序或默认连接工厂中删除"EF6" .我没有做任何reg hacks.在启动项目的app.config中重新排列add/ remove标记(在NuGet System.Data.SQLite 1.0.94.1软件包安装期间添加)是有区别的.
完成上述所有操作后,我通过NuGet将EntityFramework更新为6.1.2,并通过设计器从数据库更新模型,并在运行时访问数据仍然有效.
| 归档时间: |
|
| 查看次数: |
25111 次 |
| 最近记录: |