我在我的 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
应用程序配置文件。返回一个文件;} }
这是我的服务项目的 App.Config:
<?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="data source=HOOVERS-PC;initial catalog=Interview_MicahHoover;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
我试过删除模型中的“name=”前缀。