简体   繁体   English

使用SQL Server CE数据库部署项目

[英]Deploying a project with a SQL Server CE database

I am trying to deploy an application that uses a .SDF file and the Entity Framework. 我正在尝试部署使用.SDF文件和Entity Framework的应用程序。 Whenever the deployed application tries to use the entity (connect to the DB) I get the error: 每当已部署的应用程序尝试使用实体(连接到数据库)时,我都会收到错误消息:

The specified store provider cannot be found in the configuration, or is not valid. 在配置中找不到指定的存储提供程序,或者该存储提供程序无效。
System.ArgumentException: Unable to find the requested .Net Framework Data Provider. System.ArgumentException:无法找到请求的.Net Framework数据提供程序。 It may not be installed. 它可能没有安装。
at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) 在System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
at System.Data.EntityClient.EntityConnection.GetFactory(String providerString) 在System.Data.EntityClient.EntityConnection.GetFactory(String providerString)

My connection string looks like this: 我的连接字符串如下所示:

<add name="DBEntities" 
    connectionString="metadata=res://*/DB_Model.csdl|res://*/DB_Model.ssdl|res://*/DB_Model.msl;
    provider=System.Data.SqlServerCe.3.5;
    provider connection string=&quot;Data Source=|DataDirectory|\Database\DB.sdf&quot;" 
    providerName="System.Data.EntityClient" />

I have read somewhere that I may need to have a reference to the dll for System.Data.SqlServerCe.3.5 but I am unsure. 我在某处阅读过,我可能需要参考System.Data.SqlServerCe.3.5的dll,但不确定。 Any help would be much appreciated! 任何帮助将非常感激!

您需要在目标系统上安装3.5 SP2运行时,或按此处所述使用私有部署: http : //erikej.blogspot.com/2012/05/private-deployment-of-sql-server.html

  • Under your project properties, on the Publish tab, click Application Files . 在项目属性下的“ 发布”选项卡上,单击“ 应用程序文件”
  • Look for System.Data.SqlServerCe.dll (possibly by checking the Show All Files box). 查找System.Data.SqlServerCe.dll (可能通过选中“ 显示所有文件”框)。
  • Make sure that its Publish Status is Include . 确保其发布状态Include

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM