How to make relative path to database in app.config using SQLite/entity framework How to make relative path to database in app.config using SQLite/entity framework sqlite sqlite

How to make relative path to database in app.config using SQLite/entity framework


Use this connectionString

<add name="DWContext" connectionString="Data Source=|DataDirectory|DBPerson.s3db" providerName="System.Data.SQLite" />

Then set DataDirectory path on your code before initializing Context objext.

string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;string path = (System.IO.Path.GetDirectoryName(executable));AppDomain.CurrentDomain.SetData("DataDirectory", path);


You should be able to use the data directory substitution string:

provider connection string='data source="|DataDirectory|DBPerson.s3db"'