开发者

EntityFramework Connection problem

开发者 https://www.devze.com 2023-01-18 16:25 出处:网络
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 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 开发者_JAVA百科project).

I found that workaround posted here: 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.


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 :-)


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...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号