views:

130

answers:

2

Hi,

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=&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

+1  A: 

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.

Craig Stuntz
A: 

|DataDirectory| Substitution String from

http://msdn.microsoft.com/en-us/library/cc716756.aspx

Greg