问题描述
我写了一个C#应用程序,它使用SQL Server CE 4.0的文件,这是通过实体框架6.0通过code-首次访问。 (应用程序需要能够使用本地DLL的为SQL Server CE连接即应用程序需要XCOPY部署)。该应用程序运行得很好,我的机器,但在其他机器(例如虚拟机只用Win7和.NET 4.0),我得到一个的ArgumentException
:
I am writing a C# application which uses SQL Server CE 4.0 files, which are accessed through the Entity Framework 6.0 via code-first. (The application needs to be able to use local dll's for the SQL Server CE connection i.e. the application needs to be XCOPY deployable). The application runs fine on my development machine, but on other machines (e.g. VMs with just Win7 and .NET 4.0), I get an ArgumentException
:
ADO.NET提供与固定名称System.Data.SqlServerCe.4.0'或者未在本机或应用程序的配置文件中注册,或无法加载。详情请参阅内部异常。
的内部异常的消息说:
无法找到所需的.NET Framework数据提供。它可能没有安装。
我已经搜索谷歌和SO,大部分的评论指出,确保App.config文件是正确的。我相信我的是(默认连接工厂和供应商的部分),但这里的内容:
I have searched Google and SO and most of the comments indicate ensuring the App.config file is correct. I believe mine is (default connection factory and provider sections), but here are the contents:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<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.0" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
</configuration>
构建文件夹包括(当然,除了该应用程序特定的文件,)以下文件:
The build folder includes the following files (in addition to the application-specific files, of course):
- EntityFramework.dll
- EntityFramework.xml
- EntityFramework.SqlServer.dll
- EntityFramework.SqlServer.xml
- EntityFramework.SqlServerCompact.dll
- EntityFramework.SqlServerCompact.xml
在每个AMD64和x86子文件夹的下列文件:
In each of the amd64 and x86 subfolders are the following files:
- sqlceca40.dll
- sqlcecompact40.dll
- sqlceer40EN.dll
- sqlceme40.dll
- sqlceqp40.dll
- sqlcese40.dll
我一定程序的开发机,因为SQL Server CE已经安装上运行,但我怎么得到它仅使用本地SQL Server CE DLL的其他机器上运行?
I am certain the program runs on the development machine because SQL Server CE has been installed, but how do I get it to run using just local SQL Server CE dll's on other machines?
推荐答案
请参阅http://tech.aendeavors.com/2011/06/09/bin-deploy-sqlce-4-0-and-ef-4-1/
看来你可能缺少相关的位是:
It seems the relevant bits you might be missing are:
-
确认System.Data.SqlServerCe引用,并设置为复制地方的属性。
Make sure System.Data.SqlServerCe is referenced and set to "Copylocal" in properties.
以下内容添加到的app.config:
Add the following to app.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>
这篇关于实体Framewok code首先&QUOT; ADO.NET提供者未发现&QUOT;与本地SQL Server CE DLL的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!