与MVC 3在远程主机上使用SQL Server CE 4 [英] Using SQL Server CE 4 on a remote host with MVC 3

查看:314
本文介绍了与MVC 3在远程主机上使用SQL Server CE 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级我的主机MVC 3,但我试图做一个Hello World使用SQLCE 4.0,但我刚:

I just upgraded my host to MVC 3 but I'm trying to do a "hello world" using SQLCE 4.0 but I just got:

对不起,发生错误时
  处理您的请求。

Sorry, an error occurred while processing your request.

我看到我的布局和一切,但不是数据我看。

I see my layout and everything but instead of data I see that.

在本地主机是按预期工作

On localhost is working as expected

我有:

<add name="PruebaContext" connectionString="Data Source=|DataDirectory|db.sdf" providerName="System.Data.SqlServerCE.4.0"/>

作为的connectionString。

as connectionString.

我把自卫队作为项目的一部分,我添加了 System.Data.SqlServerCE.dll 与项目的本地副本的设置为true。

I put the sdf as part of the project, I added the System.Data.SqlServerCE.dll to the project with the local copy to true.

我没有更多的想法。该CONNSTRING,该dll位于/ bin和工作在本地主机。

I have no more ideas. The connString, the dll is in /bin and is working in localhost.

任何想法?

感谢。

修改

我有一些日志现在:

如果没有System.Data.SqlServerCE.dll依赖/ bin:

Without the "System.Data.SqlServerCE.dll" on /bin:

找不到请求的.NET Framework数据提供程序。它可能没有安装。

Unable to find the requested .Net Framework Data Provider. It may not be installed.

System.ArgumentException:无法找到所请求的.NET Framework数据提供程序。它可能没有安装。

System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.

精细不够。他们没有SqlServerCE4

Fine enough. They don't have SqlServerCE4.

通过该DLL的本地副本,AKA /斌:

With the Dll on local copy, AKA /bin:

无法加载的SQL Server Compact对应的8482.版本的ADO.NET提供本地组件安装SQL Server精简的正确版本。请参阅知识库文章974247以了解详情。

Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8482. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.

异常详细信息:System.Data.SqlServerCe.SqlCeException:无法加载的SQL Server Compact对应的8482.版本的ADO.NET提供本地组件安装SQL Server精简的正确版本。请参阅知识库文章974247以了解详情。

Exception Details: System.Data.SqlServerCe.SqlCeException: Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8482. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.

该KB说,我需要从x86和AMD64的DLL。我读的地方,如果我两个目录拷贝到/ bin中,如:/ bin中/ x86和/斌/ AMD64。我复制,从SqlServerCE 4安装文件夹的私有文件夹文件夹。现在,我得到:

The KB says that I need the dll from x86 and amd64. I read somewhere that if I copy two directories to /bin, like: /bin/x86 and /bin/amd64 . I copied that folders from the private folder of SqlServerCE 4 installation folder. Now I got:

ADO.NET提供者和SQL Server Compact的本机二进制文件,这可能导致不正确的功能之间检测可能的文件版本不匹配。这可能是由于不同版本的SQL Server精简的多个实例的presence或由于错误的二进制文件名称相同的SQL Server Compact二进制文件。请安装匹配版本的SQL Server Compact二进制文件。

Possible file version mismatch detected between ADO.NET Provider and native binaries of SQL Server Compact which could result in an incorrect functionality. This could be due to the presence of multiple instances of SQL Server Compact of different versions or due to wrong binaries with same name as SQL Server Compact binaries. Please install SQL Server Compact binaries of matching version.

确定。在SQLServerCE4的根文件夹,我有一些dll文件太多了,所以我删除了两个文件夹,并复制该DLL为/ bin:

Ok. On the root folder of SQLServerCE4 I have some dlls too, so I deleted that two folders and copied that dll to /bin:

无法加载文件或程序集文件:/// C:\\ HostingSpaces \\ jesusrod \\ foxandxss.net \\ wwwroot的\\ MVC3 \\ BIN \\ sqlceca40.dll'或它的一个依赖。该模块应包含一个程序集清单。

Could not load file or assembly 'file:///C:\HostingSpaces\jesusrod\foxandxss.net\wwwroot\mvc3\bin\sqlceca40.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

我认为我尝试了所有的东西。 Scottgu说,SqlServerCE 4应该在任何服务器上运行,无需安装。

I think that I tried all things. Scottgu said that SqlServerCE 4 should work on any server without installation.

推荐答案

我不喜欢我自己的答案回应,但工作小时后我找到了答案!

I don't like to respond to my own answer, but after hours of work I have the answer!

我们需要:

的NuGet(优于复制dll的,从程序文件)

NuGet (Better than copying the dll's from program file)

使用的NuGet我们安装:

With NuGet we install:

EF codeFirst

EFCodeFirst

SqlServerCompact

SqlServerCompact

EF codeFirst.SqlServerCompact

EFCodeFirst.SqlServerCompact

问题是,EF需要另一个DLL用于SQL CE 4(System.Data.SqlServerCe.Entity.dll),我们需要把一些配置上的web.config:

The problem was that EF need another dll for SQL CE 4 (System.Data.SqlServerCe.Entity.dll) and we need to put some configuration on web.config:

  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SqlServerCe.4.0" />
      <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
    </DbProviderFactories>
  </system.data>

就这样,所有的工作。我曾见过这样5种不同的错误,所以我们需要:

With that, all is working. I have seen like 5 different errors, so we need:

从SQL CE 4,EF DLL,web.config中的配置和本机DLL(从那里的NuGet下载库包目录)。2. DLL

The 2 dll from SQL CE 4, the EF dll, the config in web.config and the native dll (from the package directory where NuGet downloads the library).

似乎在web.config配置是指向SQL CE .dll文件和具体版本RTM包的版本是不同的。我找不到具体的版本,所以我使用该.dll从的NuGet。

It seems that the web.config config is pointing to a concrete version of the SQL CE .dll and the version of the RTM package is different. I can't find the concrete version so I use the .dll from NuGet.

这一切,SQL CE 4 + EF远程主机上。

That's all, SQL CE 4 + EF on a remote host.

这篇关于与MVC 3在远程主机上使用SQL Server CE 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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