0

I have a SQL Server CE 3.5 DB which is set to "Embedded" vis a vis Properties. The database has an associated .edmx file and entity-framework code works when I run it from VS 2010.

The app.config string is the following:

 <add name="MapProjectDB2Entities1" connectionString="metadata=res://*/MapProjectDB.csdl|res://*/MapProjectDB.ssdl|res://*/MapProjectDB.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=MapProjectDB2.sdf&quot;" providerName="System.Data.EntityClient" />

But when I Publish my project and run it from the one-click deploy folder, the exception is "The Underlying Data Provider Failed to Open".

So I need to somehow connect to my embedded database. Thanks in advance the google hits are a bit spotty for this one.

I should mention that the DB is member of a library (DLL) project, which is loaded from another project.

1 Answer 1

2

I needed to add the DB to my Exe project. From there I needed to change the config string to be the following:

The difference is only the |DataDirectory|\ part

<add name="MapProjectDB2Entities1" connectionString="metadata=res://*/MapProjectDB.csdl|res://*/MapProjectDB.ssdl|res://*/MapProjectDB.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\MapProjectDB2.sdf&quot;" providerName="System.Data.EntityClient" />
Sign up to request clarification or add additional context in comments.

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.