的EntityFramework连接问题 [英] EntityFramework Connection problem

查看:113
本文介绍了的EntityFramework连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2008中有3个项目的解决方案。一个Web应用程序和二级库。实体框架模型是一个类库和启动项目是Web应用程序。

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:

指定的命名连接或者未在配置中发现,不打算与EntityClient提供者,或不是有效的使用。

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

我固定它复制从类图书馆,实体模型位于我的web应用程序(启动项目)的web.config中的App.config的连接字符串。

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

我发现,解决办法张贴在这里:
<一href=\"http://stackoverflow.com/questions/2904672/problem-with-connectionstring-and-entityframework\">http://stackoverflow.com/questions/2904672/problem-with-connectionstring-and-entityframework

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

但是我的问题是:¿如何避免使用从web.config中的连接字符串,并使用其中的实体模型所在的app.config一个

非常感谢你。

推荐答案

我建议复制的连接字符串。这是.NET配置工程。每可执行应用程序有一个App.config中。在你的情况你的web应用程序的Web.config的的运行。

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.

您可以嵌入从EF项目的app.config到组件在执行程序集读取连接字符串并使用重载的构造函数提取出来......但留在版本1: - )

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

这篇关于的EntityFramework连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆