首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >请求现有连接字符串的ADO.NET

请求现有连接字符串的ADO.NET
EN

Stack Overflow用户
提问于 2012-10-23 18:05:53
回答 1查看 402关注 0票数 0

我在我的WCF服务项目中创建了一个ADO.NET对象,但是当我试图连接它时,我得到了以下错误:

在应用程序配置文件中找不到名为“FileEntities”的连接字符串。

这是我的代码:

public File GetFile() { using (FileEntities ctx = new FileEntities()) { File aFile = (from f in ctx.Files where f.ID == 5 select f).FirstOrDefault(); // No connection string named 'FileEntities' could be found in the 应用程序配置文件。返回aFile;}

下面是我的服务项目的App.Config:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="FileEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=HOOVERS-PC;initial catalog=Interview_MicahHoover;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

我已经尝试删除模型中的"name=“前缀。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-23 18:20:34

啊,问题是我的服务项目刚刚建了一个图书馆。使用库的项目中没有连接字符串。我将连接字符串添加到该项目中,它(大部分)可以工作。

保持这样的事情是一个理由,不把事情分解成很多项目,但WCF‘’Reilly的书推荐它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13036510

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档