views:

30

answers:

2

Hello Everyone.

I have a solution in Visual Studio 2008 with 3 projects. One Web Application and 2 class libraries. The entity framework model is in a class library and the start project is the web application.

I used to have this problem:

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

I fixed it copying the connection string from the App.config of the class library where the entity model is located to the web.config of my web application (start project).

I found that workaround posted here: http://stackoverflow.com/questions/2904672/problem-with-connectionstring-and-entityframework

But my question is: ¿how can i avoid using the connection string from the web.config and use the one from the app.config where the entity model is located?

Thank you very much.

+1  A: 

It will always use the connection string in the host application. In your case, that is the web.config. Options are to use MSBuild to rewrite the web.config...

Bryce Fischer
Thank you! I believe my answer to fabiano has another way to do it, i have to try it !
rolando
+1  A: 

I'd suggest to copy the connection string. this is .Net configuration works. Per executable application there is one App.config. In your case the Web.config of your web application that's running.

You could embed the app.config from the EF project into the assembly extract it in your executing assembly read the connection string and use the overloaded constructor... but stay with version 1 :-)

Fabiano
ok i guess if a create a server instead of only a class library i could get it to work with the app.config using the "multiple startup projects" of the project properties. Thank you for your answer!
rolando