4

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=&quot;C:\Documents and Settings\jdoe\Desktop\LcdManager\LcdManager\App_Data\monitor.sqlite&quot;'" 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

3 Answers 3

6

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=&quot;./App_Data/monitor.sqlite&quot;'" 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=&quot;|DataDirectory|/monitor.sqlite&quot;'" providerName="System.Data.EntityClient" />
Sign up to request clarification or add additional context in comments.

Comments

6

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.

3 Comments

Does that work when built on one server and deployed to another?
As long as your database is in the App_Data folder of the deployed application.
doh! yes web.config not compiled, duh me :-( This is probably the right way to do it then, not my answer.
0

I assume you're talking about this bit

C:\Documents and Settings\jdoe\Desktop\LcdManager\LcdManager\App_Data\monitor.sqlite

instead, try this

../../App_Data/monitor.sqlite

(not sure about the number of '../' but you get the idea ../../App_Data/monitor.sqlite

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.