2

Exception:

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

Method where exception happened:

/// <summary>
/// Initializes a new DSAplcEntities object using the connection string found in the 'DSAplcEntities' section of the application configuration file.
/// </summary>
public DSAplcEntities() : base("name=DSAplcEntities", "DSAplcEntities")
{
      this.ContextOptions.LazyLoadingEnabled = true;
      OnContextCreated();
 }

What exactly does this exception mean and how can I fix it?

4

2 回答 2

1

Found the solution. The problem was that I was using WCF Services in my project and I did not copy the connection string to the App.Config inside the service solution.

于 2013-05-19T22:34:54.283 回答
0

The string arguments passed to the base class constructor are used to pass in either a named connection string (defined externally in a config file) or the connection string itself, depending on which constructor is invoked.

It looks like you're invoking the constructor on ObjectContext that takes two arguments, the first of which must be a valid connection string. The string you are passing in is not a valid EF connection string, which is why you get the error message from EF.

Check if you have the actual connection string defined in your config file. Note what name it has been defined with and pass in that name as the first argument (and if that doesn't work, try removing the second argument - I'm not sure if the method you're calling accepts a named connection string).

于 2013-05-19T22:18:07.880 回答