ADO.NET实体连接字符串的多个项目 [英] ADO.NET Entity Connection String for Multiple Projects

查看:215
本文介绍了ADO.NET实体连接字符串的多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的多层项目中,数据模型承载ADo.NET实体模型和数据访问层做验证。

I am using multiple layer project where the DataModel hosts the ADo.NET Entity model and DataAccess layer does the validation.

不过,每次我得到这样一个错误

However everytime I get a error like this

时,或者未在配置找到指定命名连接,并不意在与EntityClient提供者使用的,或不是有效的。

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

我试图连接字符串

<添加名称=SalesEntities connectionString="metadata=res://*/SalesEntities.csdl|res://*/SalesEntities.ssdl|res://*/SalesEntities.msl;provider=System.Data.SqlClient;provider连接字符串=安培; QUOT;数据源=;初始目录=凤凰;集成安全性= TRUE; MultipleActiveResultSets =真放; QUOT;的providerName =System.Data.EntityClient/>

<添加名称=SalesEntities connectionString="metadata=.\SalesEntities.csdl|.\SalesEntities.ssdl|.\SalesEntities.msl;provider=System.Data.SqlClient;provider连接字符串=安培; QUOT;数据源=;初始目录=凤凰;集成安全性= TRUE; MultipleActiveResultSets =真放; QUOT;的providerName =System.Data.EntityClient/>

<add name="SalesEntities" connectionString="metadata=.\SalesEntities.csdl|.\SalesEntities.ssdl|.\SalesEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=Phoenix;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

也尝试过其他的组合是指被叫项目目录,但没有运气的根目录。

also tried other combinations to refer the Root Directory of the Called project directory but no luck.

任何帮助是非常AP preciated。非常感谢一如既往:)。

Any help is highly appreciated. Many Thanks as always :).

推荐答案

您必须把这些连接字符串中的每个应用程序的app.config文件。如果您有生成的模型中,然后尝试消耗DAL在一个EXE同样的事情会发生一个DAL。该EXE不知道连接字符串。

You have to put those connection strings in each applications app.config file. If you have a DAL that you generated the model in, and then try to consume the DAL in an EXE the same thing will happen. The EXE does not know the connection string.

我发现最简单的就是把一个app.config上的每一个项目,只是复制从我在最初生成模型DAL连接字符串。然后每个将具有相同的连接字符串的副本。

The easiest thing I have found is to put an app.config on each project and just copy the connection string from the DAL I generated the models in originally. Then each will have a copy of that same connection string.

这篇关于ADO.NET实体连接字符串的多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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