vendredi 4 septembre 2015

Unable to open database file after changing connection string, SQLite, Visual Studio

I have a ASP.NET MVC solution with 2 projects: DAL and web project. I used to connect to my SQLite database using local file path in connection string of both projects' web.config files:

Web.configs of DAL and Web projects:

<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\Admin\Documents\Visual Studio 2013\Projects\Myproj\Myproj.db3&quot;'" 
providerName="System.Data.EntityClient" />

Everything was working fine, and then I needed to change connection string using DataDirectory, so that I could correctly deploy the website. I added the db file into App_Data folder of WEB project and both web.configs changed to:

<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;|DataDirectory|\Myproj.db3&quot;'" 
    providerName="System.Data.EntityClient" />

Now, I can connect to the db extract data via code, but I cannot open database in server explorer and use designer, the error is: "Unable to open database file".

I would appreciate any help!

Aucun commentaire:

Enregistrer un commentaire