我有一个项目,我刚刚更新了使用nuget。这个更新后的实体框架从6.1更新到6.1.1,并将sqlite更新为1.0.93。我想从我最新的数据库中更新我的模型。我从数据库中完成了以下步骤: 1)模型;2)选择sqlite数据库;3)生成
在生成之后,我收到了如下错误消息。我已经安装了1.0.93设计时组件。有人知道是什么导致了这个错误吗。项目引用和版本都与上述版本相匹配。
错误信息:
您的项目引用最新的实体框架;但是,无法为您找到与此版本兼容的实体框架数据库提供程序。
更新:
最后,我使用包管理器控制台手动安装了6.1.0
安装-软件包EntityFramework -Version 6.1.0
然后在我的csporj文件中替换
软件包\EntityFramework.6.1.1
使用
软件包\EntityFramework.6.1.0
我尝试从数据库创建EF设计器,从数据库首先创建代码,但我仍然得到相同的错误。
更新
我已经按照汤姆提供的指示,感谢您抽出时间深入回答,我们对此表示感谢。但我无法让实体框架设计器使用SQLite 1.0.93。我所发现的:
1)如汤姆所述,当我从tools菜单中添加SQLite数据源时,我看到了SQLite数据提供程序。
2)但是当我重新启动visual studio时,数据源没有连接
3)数据源可以刷新,重新启动后有效。
4)添加新数据项,但SQLite未被列为提供程序
我已经双重检查了注册表,EF6被附加到不变名称,SQLite dll在GAC中注册。我会试着看看我还能找到什么,但此时我不知道该找什么。顺便提一句,我已经尝试过dotConnect,它也不适用于EF6.1.1。
更新2
是否有人知道实体框架设计器是否有一个日志选项来查找可能发生的事情?
发布于 2014-08-07 02:13:16
Update :使用VisualStudio2013Update4 (Pro和终极版)以及Sqlite和EF的最新版本的更简单的解决方案,请查看下面发布的解决方案“broslav”。不知道它是否适用于快报版。
好吧,这是个建议。这不适用于版本。此外,我也不知道如何让它对现有项目进行更新。这绝对是屁股上的痛。我还没有测试是否所有东西都是必需的,但这应该是可行的:
首先,不要将NuGet包用于SQLite,而是从这里下载程序集安装程序:http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
安装32位Windows (.NET Framework4.5.1)安装程序:.NET (10.00 MiB) (不是64位版本)。这是唯一和设计师在一起的。
安装并选择在GAC中安装,并为VS13安装设计器。
对于下面的内容,的精确顺序非常重要!
我制作了一个关于这些步骤的视频--,参见:http://vimeo.com/103372740
用VS13创建一个项目。将构建明确地指向框架4.5.1和x86。保存并构建。
接下来,从NuGet安装最新的EF 6软件包(6.1.1)。保存并构建。
手动添加对已安装的SQLite程序集(包括设计器)的引用,在程序集下的参考管理器下,您可以找到扩展选项,用于选择GAC中添加的四个程序集: System.Data.SQLite Core + Designer + for Entity Framework + for LINQ。保存并构建。
然后在“工具”下通过“连接到数据库”创建到数据库的连接。在进行任何其他操作之前,先保存和构建,然后重新启动 Visual。在启动ADO.NET实体数据模型向导之前,不要做任何其他事情,所以不要刷新数据库连接。
添加一个ADO.NET实体数据模型,选择Generate数据库。您的数据库连接将显示在下拉列表中。将其保留在那里,但无论如何选择创建一个新连接,并再次选择完全相同的数据库(就好像您正在创建一个新连接)。听起来很傻,但这很关键,见下面的图片.
当我以这种方式添加了一个ADO.NET实体数据模型时,它确实出现了一个恼人的错误,但是下一个按钮是可选的,所有的东西都可以工作(令人惊讶的是)!
设计器工作,检索数据和写入数据工作。
但还没有在另一台机器上测试部署.我用的是Win7 64位.
更改了UPDATE:要获得正确的配置才能真正访问数据库,您必须在执行上述all之后从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”,反之亦然。
**这是不是越来越荒谬了?是的,就是这样!这让我很头疼..。**
发布于 2015-02-17 11:44:56
这就是对我有用的东西:
add
和remove
项在app.config中的DbProviderFactories
标记中。所以我收到的包裹是:
<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>
为我工作的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>
正如您最终所看到的,对我来说,没有必要从invariantName
中删除“invariantName
”,也没有必要删除或重新排列其他提供程序或默认连接工厂。我不需要做任何黑客攻击。在启动项目的add
/remove
标记(在NuGet System.Data.SQLite 1.0.94.1包安装过程中添加的标记)中重新排列会产生不同的效果。
在所有这些之后,我通过EntityFramework将NuGet更新为6.1.2,并且通过designer从数据库更新模型和在运行时访问数据仍然有效。
发布于 2015-08-26 06:05:38
最后,我有了一些步骤来一致地向项目中添加Sqlite和EF6:
EF6: 6.0.0版本为6.1.3 (目前是最新版本)。System.Data.Sqlite: 1.0.93-1.0.95,但不是1.0.98 (目前是最新版本)。
为了避免获得System.Data.Sqlite 1.0.98,请不要使用Nuget软件包管理器进行安装。手动安装System.Data.Sqlite。不幸的是,http://system.data.sqlite.org/并没有列出以前的下载。
我使用Nuget并安装EF6,然后手动添加System.Data.Sqlite库。我多次尝试使用1.0.98,但我不能
对于我的实现,我首先使用数据库--手动编写实体数据类。
public partial class MyDbContextEF : DbContext
{
public MyDbContext() : base("name=MyDbContext") { }
public DbSet<DataRecord> DataRecords { get; set; }
}
[Table("TableName")]
public class DataRecord
{
[Key]
public Int64 RowID { get; set; }
public string Name { get; set; }
}
https://stackoverflow.com/questions/25089346
复制相似问题