【发布时间】:2014-10-13 21:06:00
【问题描述】:
我创建了一个类库项目,其中包含实体框架对象,该对象将负责我的多个项目的公共数据访问层。将生成的 dll 文件添加到我的域项目中,并使用类库项目中的实体对象后,我面临以下问题。
在应用程序配置文件中找不到名为“ABC”的连接字符串。
我已将 edmx 的 Metadata Artifact 处理属性设置为 Embed in Output Assembly。
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="ABC" connectionString="metadata=res://*/Entity.ABC.csdl|res://*/Entity.ABC.ssdl|res://*/Entity.ABC.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\ABC.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
</configuration>
实体代码如下
public ABC_IntegrationEntities()
: base("name=ABC")
{
}
还有一件事:我正在从数据目录“App_Data”访问数据库。
我引用了dotnetcurry.com的博客。
【问题讨论】:
-
要回答这个问题,我们需要查看您的 app.config 文件内容以及 Context 类(Object 或 Db)的构造函数。
-
嗨,rob,我已经更新了我的问题,请看一下。谢谢
-
配置文件中当前名为“Gumu_IntegrationEntities”的connectionString需要改名为“ABC”。
标签: c# asp.net-mvc entity-framework wcf service