[英]Entity Framework - how can I change connection string to be relative?
Can someone confirm how to change the auto-generated connection string for an entity framework application so that it is relative? 有人可以确认如何更改实体框架应用程序的自动生成的连接字符串以使其相对吗?
That is so it will work for anyone who downloads and installs the application. 这样一来,它将适用于下载和安装该应用程序的任何人。 That is, currently the connection string auto-generated for me has an absolute path in it. 也就是说,当前为我自动生成的连接字符串中具有绝对路径。 See below for an example: 参见以下示例:
<add name="Model1Container" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SQLite;provider connection string='data source="C:\Documents and Settings\Owner\My Documents\My Dropbox\source\MyProject\MyProjectLibrary\MyProject.sqlite"'" providerName="System.Data.EntityClient" />
I should note that in my solution the UI application project uses a separate business logic layer project where the Entity Framework model is. 我应该注意,在我的解决方案中,UI应用程序项目使用一个单独的业务逻辑层项目(实体框架模型在其中)。 I have been copying the auto-generated connection string from this latter project to the UI project to get things to work. 我一直在将自动生成的连接字符串从后一个项目复制到UI项目中,以使事情正常进行。
thanks 谢谢
|DataDirectory| | DataDirectory目录| Substitution String from 来自的替换字符串
http://msdn.microsoft.com/en-us/library/cc716756.aspx http://msdn.microsoft.com/en-us/library/cc716756.aspx
You can edit the auto-generated connect string to anything you want. 您可以将自动生成的连接字符串编辑为所需的任何内容。 So long as it's valid, the EF won't care. 只要有效,EF就不会在意。
Perhaps you're really asking "Can SQLLite use a relative connect string?" 也许您真的在问“ SQLLite可以使用相对连接字符串吗?” I don't know, but that has nothing to do with the EF. 我不知道,但这与EF无关。 If it can, the EF will work with it. 如果可以,EF可以使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.