[英]Checklist when deploying SQLite with .NET application
I need to deploy SQLite file with WPF application. 我需要使用WPF应用程序部署SQLite文件。
I'd like to have a shortlist what must be considered when deploying the application that includes a SQLite database file in it. 我想列出一个短名单,以部署包含SQLite数据库文件的应用程序时应考虑的事项。
So far, I have referenced and set Copy Local to True for: 到目前为止,我已经为以下内容引用并将“本地复制”设置为True :
.and I have two interops where Copy to Output Directory I left to be the default Copy Always 。并且我有两个互操作,其中将“复制到输出目录”保留为默认“始终复制”
In the app.config file I have: 在app.config文件中,我有:
<applicationSettings>
<MyApp.MySettings>
<setting name="connStrSQLite" serializeAs="String">
<value>data source="C:\MyFolder\MySQLiteFile.sqlite3"</value>
</setting>
</MyApp.MySettings>
</applicationSettings>
and 和
<connectionStrings>
<add name="MyEntities" connectionString="metadata=res://*/Model.ORM.MyModel.csdl|res://*/Model.ORM.MyModel.ssdl|res://*/Model.ORM.MyModel.msl;provider=System.Data.SQLite;provider connection string='data source="C:\MyFolder\MySQLiteFile.sqlite3"'" providerName="System.Data.EntityClient" />
</connectionStrings>
I suppose in the app.config the paths are not working on deployed application since they are referring to my local folder now. 我想在app.config中,路径在已部署的应用程序上不起作用,因为它们现在是指我的本地文件夹。 How to modify them ?
如何修改它们 ?
Then, I checked for example from here SQLite deployment for .net application that the following should be added to app.config file. 然后,例如,我从此处检查.net应用程序的SQLite部署是否应将以下内容添加到app.config文件中。
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
Anything else? 还要别的吗?
regarding your connection string - for ClickOnce installation you should use |DataDirectory| 关于您的连接字符串-对于ClickOnce安装,应使用| DataDirectory | substitution instead of full path - runtime will automatically convert this into proper local path:
替代完整路径-运行时将自动将其转换为正确的本地路径:
<connectionStrings>
<add name="MyContext" connectionString="DataSource=|DataDirectory|Mydb.sdf" providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.