开发者

Entity Framework - how can I change connection string to be relative?

开发者 https://www.devze.com 2023-01-18 09:30 出处:网络
Can someone confirm how to change the auto-generated connection string for an entity framework application so that it is 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 开发者_如何学Cwork 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=&quot;C:\Documents and Settings\Owner\My Documents\My Dropbox\source\MyProject\MyProjectLibrary\MyProject.sqlite&quot;'" 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. I have been copying the auto-generated connection string from this latter project to the UI project to get things to work.

thanks


|DataDirectory| Substitution String from

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.

Perhaps you're really asking "Can SQLLite use a relative connect string?" I don't know, but that has nothing to do with the EF. If it can, the EF will work with it.

0

精彩评论

暂无评论...
验证码 换一张
取 消