vendredi 4 septembre 2015

DB file path from project resources in Web.config ASP.NET MVC

I have a SQLite database file located outside the project and the connection string refers to it like:

<add name="DBEntities" 
connectionString="metadata=http://res*/Models.Model.csdl|res*/Models.Model.ssdl|res*/Models.Model.msl;provider=System.Data.SQLite;
provider connection string='data source=&quot;C:\Users\XUser\Documents\Visual Studio 2013\Projects\MyProj\MyProjDB.db3&quot;'" 
providerName="System.Data.EntityClient" />

Rather than pointing to a local file path: "C:\Users\XUser\Documents..." I would like to add this DB file into project resources folder, and refer to it in connection string like "~/Resources/MyProjDB.db3".

I'm not sure if this is right approach and would appreciate any advice.

Aucun commentaire:

Enregistrer un commentaire