Relative path inside app.config

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
caipigott
Posts: 5
Joined: Fri 10 Apr 2015 08:52

Relative path inside app.config

Post by caipigott » Wed 15 Apr 2015 14:09

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Relative path inside app.config

Post by Shalex » Thu 16 Apr 2015 12:20

You can use a relative path (it starts from the directory where the assembly of your application resides).

caipigott
Posts: 5
Joined: Fri 10 Apr 2015 08:52

Re: Relative path inside app.config

Post by caipigott » Thu 16 Apr 2015 12:49

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Relative path inside app.config

Post by Shalex » Thu 16 Apr 2015 16:29

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

caipigott
Posts: 5
Joined: Fri 10 Apr 2015 08:52

Re: Relative path inside app.config

Post by caipigott » Fri 17 Apr 2015 07:41

Hi,

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

Thanks and greetings,
Caipigott

Post Reply