数据库首先使用system.data.sqlite 1.0.93创建实体框架6.1.1模型 [英] Database first create entity framework 6.1.1 model using system.data.sqlite 1.0.93

查看:201
本文介绍了数据库首先使用system.data.sqlite 1.0.93创建实体框架6.1.1模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我刚刚更新使用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文件中替换



packages\EntityFramework.6.1.1





packages\EntityFramework.6.1.0



我尝试从数据库和代码优先创建EF Designer从数据库,但我仍然收到相同的错误。



更新



遵循汤姆提供的说明,并感谢时间采取时间深度反应,这是值得赞赏的。但是,我无法让实体框架设计人员使用SQLite 1.0.93。我发现:



1)当我从Tom工具菜单中添加SQLite数据源时,我看到SQLite数据提供者。





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





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





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





我已经检查了注册表,EF6被附加到不变名称,SQLite dll在GAC注册。我会尝试看看还能找到什么,但在这一点上,我不知道该怎么找。作为附注,我尝试过dotConnect,它不适用于EF 6.1.1。



更新2



有谁知道实体框架设计器是否有一个日志记录选项来找出可能发生的情况?

解决方案

[更新:为了使Visual Studio 2013 Update 4(Pro和Ultimate)以及最新版本的Sqlite Providers和EF可以使用更简单的解决方案,请查看下面的解决方案broslav。不知道它是否适用于Express版...]



好的,这是一个建议。这不适用于Visual Studio Express版本。
另外,我不知道如何让它适用于现有项目的更新。
这是对屁股的绝对痛苦。
我没有测试是否需要一切,但这应该是有效的:



首先,不要将NuGet软件包用于SQLite,而是下载程序集安装程序从这里:
http://系统。 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中安装并安装VS13的Designer。



对于以下内容,确切顺序很重要!



我制作了这些步骤的视频 ,请参阅: http://vimeo.com/103372740



在VS13中创建一个项目。将构建明确地定位到框架4.5.1和x86。保存并构建。



接下来,从NuGet安装最新的EF 6软件包(6.1.1)。保存并构建。



手动添加对已安装的SQLite程序集(包括Designer)的引用,在程序集下的引用管理器下,您可以找到扩展名选项, GAC中的程序集:System.Data.SQLite Core + Designer + for Entity Framework + for LINQ ..保存并构建。



然后通过连接创建与数据库的连接到工具下的数据库。在您做任何其他保存和构建之前,然后重新启动 Visual Studio。在启动ADO.NET实体数据模型向导之前,请勿执行任何操作,因此请勿刷新数据库连接。



添加ADO.NET实体数据模型,选择生成从数据库。
您的数据库连接将显示在下拉列表中。保留在那里,但选择创建一个新连接,再次选择完全相同的数据库(好像你正在创建一个新的连接)。这听起来很傻,但至关重要的是看下面的图片...





当我以这种方式实际添加了ADO.NET实体数据模型时,它提供了令人讨厌的错误,但是下一步按钮是可选择的



设计师的作品,检索数据和撰写数据的作品。



没有在另一台机器上测试部署,但...我正在使用Win7 64位。



更改更新:要获得正确的配置以实际访问数据库,您必须在执行上述所有之后从NuGet安装System.Data.SQLite.EF6软件包,然后添加
< provider invariantName =System.Data.SQLitetype =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,反之亦然。 / p>

**这是否可笑?是的!这让我很头痛... **


I have a project that I just updated using nuget. This updated entity framework from 6.1 to 6.1.1, and it updated sqlite to 1.0.93. I wanted to update my model from my latest database. I did the steps of 1) Model from Database 2) Select sqlite database 3) Generate

After the generation I received the following error message shown below. I have the 1.0.93 design time components install. Does anyone know what exactly is causing this error. The project references and versions all match the versions shown above.

Error Message:

Your project references the latest Entity Framework; however and Entity Framework database provider compatible with this version could not be found for you data connection.

Update:

I ended up installing 6.1.0 manually using the package manager console

Install-Package EntityFramework -Version 6.1.0

Then in my csporj files replacing

packages\EntityFramework.6.1.1

with

packages\EntityFramework.6.1.0

I tried creating EF Designer from Database and Code First from Database but I am still getting the same error.

UPDATE

I have followed the instructions Tom has provided, and thanks time for taking the time to respond in depth it is appreciated. But I cannot get the entity framework designer to work with SQLite 1.0.93. What I have found:

1) When I add the SQLite data source from the tools menu as Tom describes I see the SQLite data provider.

2) But when I restart visual studio the data source is not connected

3) The data source can be refreshed and it is valid after restart

4) Add new data item but SQLite is not listed as a provider

I have double checked the registry and EF6 is appended to the invariant name, the SQLite dlls are registered in the GAC. I will try to see what else I can find but at this point I am not sure what to look for. As a side note I have tried dotConnect and it does not work either with EF 6.1.1.

Update 2

Does anyone know if the Entity Framework Designer has a logging option to find out what might be happening?

解决方案

[ UPDATE : for an easier solution that works with Visual Studio 2013 Update 4 (Pro and Ultimate) and recent versions of Sqlite Providers and EF, look at the solution 'broslav' posted below. Don't know if it works with Express editions... ]

Ok, this is a suggestion. This does NOT work for Visual Studio Express editions. Also, I'm not sure how to get it to work for an update of an existing project. And it is an absolute pain in the butt. I haven't tested if everything is required, but this should work:

First, do NOT use the NuGet package for SQLite, but download the assembly installer from here: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

Install the Setups for 32-bit Windows (.NET Framework 4.5.1) installer: sqlite-netFx451-setup-bundle-x86-2013-1.0.93.0.exe (10.00 MiB) (NOT the 64-bit version). This is the only one with the designer.

Install and select to install in the GAC and install the Designer for VS13.

For the following, the exact order is important!

I made a video of these steps, see: http://vimeo.com/103372740

Create a project in VS13. Target the build to framework 4.5.1 and x86 explicitly. Save and build.

Next, install the latest EF 6 package (6.1.1) from NuGet. Save and build.

Manually add references to the installed SQLite assemblies (including the Designer) , under the Reference Manager under Assemblies you can find the Extensions option for selecting the four added assemblies in the GAC : System.Data.SQLite Core + Designer + for Entity Framework + for LINQ.. Save and build.

Then create a connection to your database via Connect to Database under Tools. Before you do anything else Save and Build and then RESTART Visual Studio. DO NOT DO ANYTHING ELSE before starting the ADO.NET Entity Data Model wizard, so DO NOT refresh the database connection.

Add an ADO.NET Entity Data Model, select Generate from Database. Your database connection will show up in the drop-down list. Keep it there, but select to create a New Connection anyway and select the exact same database again (as if you are creating a new connection). It sounds silly, but it is crucial, see image below...

When I actually Added an ADO.NET Entity Data Model this way it did present the annoying error, but the Next button is selectable and everything worked regardless (amazingly)!

Designer works, retrieving data and writing data works.

Haven't tested deployment on another machine though... I'm using Win7 64-bit.

CHANGED UPDATE: To get the correct configuration to actually access the database, you have to install the System.Data.SQLite.EF6 package from NuGet after doing all of the above, then add <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> to the App.Config and remove the other providers and remove everything in between <system.data></system.data>, otherwise you'll get some exception. But note that this means that every time you want to update the EDMX model, you have to change the App.Config invariantName="System.Data.SQLite" to invariantName="System.Data.SQLite.EF6" and vice versa.

** Is this getting ridiculous? Yes, it is! And it gave me quite a headache... **

这篇关于数据库首先使用system.data.sqlite 1.0.93创建实体框架6.1.1模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆