views:

61

answers:

1

Here's a screenshot of the error:

alt text

The error itself is:

The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Going to the app.config file of that same project I can find:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="DocumentsEntities" connectionString="metadata=res://*/Documents.csdl|res://*/Documents.ssdl|res://*/Documents.msl;provider=System.Data.SQLite;provider connection string='data source=&quot;D:\Programming Projects\Desktop Applications\C#\DocumentScanner\DAL\Documents.sqlite&quot;'" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

The connection string does exist but I'm getting this error.

I'm using SQLite and .NET Framework 3.5.

Any suggestions?

A: 

Have you seen this answer? Does it help?

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/f5904b4d-b2f8-421e-90de-339f93959533/

Quoting:

My only guess is the app.config is not in the binary directory where the exe is. Please do the following: 1. Visually verify that the app.config with the expected content is in the directory where the exe is compiled. (Existence in the project root directory is not enough.) 2. Use System.Configuration.ConfigurationManager from within your app to examine the content of the app.config your exe is using. I’m also looking at the content of the connection string, and I can say that it may not work in a multi project environment (unless you’ve duplicated the EDM in each project). The reason for that is “.” resolves to the directory where the exe is loaded from. If you want to reuse the same EDM, you at least have to make a few steps back in the path and then navigate to the project where the EDM is, e.g. “......\Proj1\AdventureWorksModel”. Additionally you may consider using the |DataDirectory| macro - when you load an AppDomain you can set |DataDirectory| to point to the exact directory where the EDM is, and then use that in the connection string, e.g.

“|DataDirectory|\AdventureWorksModel”. If you are working on an ASP.NET project, you can use “~” which refers to the project root. In that latter case, you can’t reference a model outside your project’s hierarchy though.

Zlatko Michailov Program Manager, 

Data Programmability Runtime Microsoft Corp.

drachenstern