在安装了iis的 Windows 7的干净安装上(未安装mvc 4和sql compact 4.0).
我在db项目上安装了以下nuget包:
> EntityFramework(版本6.0.0-alpha2)
> EntityFramework.sqlServerCompact(Version 6.0.0-alpha2)
> Microsoft.AspNet.Providers(版本1.2)
> Microsoft.AspNet.Providers.Core(版本1.2)
> Microsoft.sqlServer.Compact(版本4.0.8876.1)
在web.config中,我得到了以下配置:
<connectionStrings> <add name="[Name]" connectionString="Data Source=|DataDirectory|[FileName].sdf" providerName="System.Data.sqlServerCe.4.0" /> </connectionStrings> ...................... <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.sqlConnectionFactory,EntityFramework"> <parameters> <parameter value="System.Data.sqlServerCe.4.0" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.sqlServerCe.4.0" type="System.Data.Entity.sqlServerCompact.sqlCeProviderServices,EntityFramework.sqlServerCompact,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" /> </providers> </entityFramework>
Bin文件夹(sql ce文件位于amd64和x86文件夹中:
> [amd64]
> [x86]
> Antlr3.Runtime.dll
> DotNetOpenAuth.AspNet.dll
> DotNetOpenAuth.Core.dll
> DotNetOpenAuth.OAuth.Consumer.dll
> DotNetOpenAuth.OAuth.dll
> DotNetOpenAuth.OpenId.dll
> DotNetOpenAuth.OpenId.RelyingParty.dll
> EntityFramework.dll
> EntityFramework.sqlServer.dll
> EntityFramework.sqlServer.xml
> EntityFramework.sqlServerCompact.dll
> EntityFramework.sqlServerCompact.xml
> EntityFramework.xml
> Microsoft.Web.Infrastructure.dll
> Microsoft.Web.WebPages.OAuth.dll
> Newtonsoft.Json.dll
> ShipMedProto.DB.dll
> ShipMedProto.DB.pdb
> ShipMedProto.Web.dll
> ShipMedProto.Web.pdb
> System.ComponentModel.DataAnnotations.dll
> System.Data.DataSetExtensions.dll
> System.Data.sqlServerCe.dll
> System.Data.sqlServerCe.Entity.dll
> System.Net.Http.Formatting.dll
> System.Web.Helpers.dll
> System.Web.Http.dll
> System.Web.Http.WebHost.dll
> System.Web.Mvc.dll
> System.Web.Optimization.dll
> System.Web.Providers.dll
> System.Web.Razor.dll
> System.Web.WebPages.Deployment.dll
> System.Web.WebPages.dll
> System.Web.WebPages.Razor.dll
> WebActivatorEx.dll
> WebGrease.dll
> WebMatrix.Data.dll
> WebMatrix.WebData.dll
当我部署到干净的机器时,我收到以下错误消息:
无法找到请求的.Net Framework数据提供程序.它可能没有安装.
在我的开发机器上它工作正常. (我安装了sql ce)
我有什么问题吗?
解决方法
添加它应该添加上面答案中的等效字符串.我最终在web.config(或app.config,如果你正在做一个应用程序)中这样做了
<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> <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,PublicKeyToken=89845dcd8080cc91" /> </DbProviderFactories> </system.data>
对不起,我迟到了一年,但希望这有助于其他人.