Loading ...

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

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

 /5
0 (0votes)

Interesting problem which I've seen asked several times within Microsoft forums and blogs, mostly asked by those who are just starting with Entity Framework.

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

In case when you have an ASP.NET Web Application project and you create Entity Framework model in separated Class Library project. Once you reference the dll from the Class Library project where you have the Entitiy Framework model, when you will create instance of the model, for example:

using (MyModelEntities context = new MyModelEntities())
{
//
}

the application will throw the above-mentioned error.

Why this happens? The connection strig is automatically created in the App.config file on root of Class Library project where EF model is placed.Зашто се случува ова? On the other hand we create instance of MyModelEntities on the web application level, so by default  the application searches for the connection string inside Web.config.

Very quick and simple solution is to copy the connection string from App.config (in Class Library project where you have the EF model) in Web.config of the web application.

This will permanently solve the issue!

Hope this was helpful.

The same blog in Macedonian language: http://mkdot.net/blogs/hajan/archive/2011/02/24/the-specified-named-connection-is-either-not-found-in-the-configuration-not-intended-to-be-used-with-the-entityclient-provider-or-not-valid.aspx

Comments (no comments yet)

  • :*
  • :*
  • :
 *

Top Posts