I have the following tag in my ASP.NET Web.config application:
<add name="monitorEntities" connectionString="metadata=res://*/Models.MonitorDB.csdl|res://*/Models.MonitorDB.ssdl|res://*/Models.MonitorDB.msl;provider=System.Data.SQLite;provider connection string='data source="C:\Documents and Settings\jdoe\Desktop\LcdManager\LcdManager\App_Data\monitor.sqlite"'" providerName="System.Data.EntityClient" />
that refers to an EntityFramework instance mapping a sqlite db located in the App_Data directory of the application.
How can i make the link relative so that deploying in a production environment is easier?
Thanks
Have you tried
<add name="monitorEntities" connectionString="metadata=res://*/Models.MonitorDB.csdl|res://*/Models.MonitorDB.ssdl|res://*/Models.MonitorDB.msl;provider=System.Data.SQLite;provider connection string='data source="./App_Data/monitor.sqlite"'" providerName="System.Data.EntityClient" />
or
<add name="monitorEntities" connectionString="metadata=res://*/Models.MonitorDB.csdl|res://*/Models.MonitorDB.ssdl|res://*/Models.MonitorDB.msl;provider=System.Data.SQLite;provider connection string='data source="|DataDirectory|/monitor.sqlite"'" providerName="System.Data.EntityClient" />
Can't you use "|DataDirectory|" in the connection string (instead of C:...\App_Data)? E.g:
connectionString="... |DataDirectory|\monitor.sqlite ..."
I know this works for SQL Server Express databases that are deployed in the app_data folder of the application. But I don't know if this works for Entity Framework / SQLite.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With