Page 1 of 1

Relative path inside app.config

Posted: Wed 15 Apr 2015 14:09
by caipigott
Hello,

so far we have these line inside our app.config of our software

<connectionStrings><add name="ScrewDataContext" connectionString="metadata=res://*/ScrewDataModel.csdl|res://*/ScrewDataModel.ssdl|res://*/ScrewDataModel.msl;provider=Devart.Data.SQLite;provider connection string="data source=\\svtb24sd\Data\Software\Datenbank\Version1.0\database.db"" providerName="System.Data.EntityClient" /></connectionStrings>

What we want now is to change the data source to something like

"..\..\database.db"

instead of

"\\svtb24sd\Data\ ...."

Is this possible to use a relative path or does the provider need an absolute one.

Many thanks in advance,
Caipigott

Re: Relative path inside app.config

Posted: Thu 16 Apr 2015 12:20
by Shalex
You can use a relative path (it starts from the directory where the assembly of your application resides).

Re: Relative path inside app.config

Posted: Thu 16 Apr 2015 12:49
by caipigott
Hi,

thanks for your reply.
The problem we are facing is kind of different (i also understood it the way you did when my collegue told me to write).
We are using the entity framework and the model is generated from the database. So, when we change the database, we have to update the model from database inside the designer. The database itself (our reference database) is part of the project.
What we need now is to set the Path of the database inside the app.config relativ because not everyone in out team has the Project saved at the same place.

Sorry for my bad english, i hope you could understand.

Greetings,
Caipigott

Re: Relative path inside app.config

Posted: Thu 16 Apr 2015 16:29
by Shalex
Example
C:\MySolution\MyProject\Database.db
C:\MySolution\MyProject\bin\Debug\MyApplication.exe
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe

Relative paths
1) in runtime (Database.db is used by MyApplication.exe):
..\..\Database.db
2) in design time (Database.db is used by devenv.exe):
..\..\..\..\MySolution\MyProject\Database.db

Re: Relative path inside app.config

Posted: Fri 17 Apr 2015 07:41
by caipigott
Hi,

many thanks for your fast reply and your help - it helped us a lot.

Thanks and greetings,
Caipigott