Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I suspect that your issue is coming from the fact that you have more than one project in your solution and the one that contains your entity framework stuff including edmx files is NOT the solutions's startup project. In this case even if the connection string exists in the EF app.config project, still CLR cannot find it at runtime. For example, if you have a web site and a EF project in your solution, you need to copy the connection string from the EF project's app.config to your website's web.config. Basically, any connection string data should exist in the config file of the project that the .Net threads initiated from by CLR (i.e. your startup project). If this is not your case, then just open your edmx file, right click on its surface, select properties and copy the connection string and paste it into your app.config Connection String section. This way you can make sure that you are having the correct one in your config.

EDIT:
As you can see here on Documenation on ObjectContext Constructor, the first parameter is the connectionstring name which is code generated at the time you create your EDM. If, somehow, the name of your connectionstring name happens to be changed, all you need to do is right clicking on your model and selecting "Update Model From Database..." then follow the wizard to update your confing and designer to reflect this change.


You need to copy the connection string in the app.config to your web.config, or copy the entire file to the project which displays the output. It is one of the conditions to consume the framework.


I ran into this problem when I tried to put my custom database logic in a .dll to be used by multiple projects in my solution.

While the .dll had the correct app.config file, it didn't work. Entity frameworks wanted the connection information in the app.config of the .exe. Copying the information to there worked just fine.

Morteza's solution of pasting the connection string directly into the .edmx didn't work for me, as it wouldn't let me paste the value in there -- although that's precisely what I wanted to be able to do.


Hi I had this problem and it was making me nuts. Anyway finally I figured out what the problem was. First thing you have to do is make sure that the connectionstrings in app.config and web.config are the same. Then you must double click on the .edmx file so you can see the tables. Once u are click anywhere near the tables but not on the tables and go to properties. From the dropdown list select the ConceptualEntityModel and search for the Entity Container Name and remember it well.

Next go to the designer of the edmx file and open the constructors. (the designer is the subfolder of the edmx file) the constructors should have two parameters in the BASE parameter

public DBEntities() : base("name=DBEntities", "DBEntities")
    {
        this.ContextOptions.LazyLoadingEnabled = true;
        OnContextCreated();
    }

this is one of them. the first parameter should have the name of the project file in which the .edmx file is in. The second parameter must have the name of the entity container name from the properties I mentioned earlier about. do not forget to arrange all the constructors with the : base("", "")

Atleast that was my problem and my problem was solved like that. I hope u manage to solve yours like this.