[英]No connection string named 'KgSoftProContext' could be found in the application config file
I've added the DLL in my project database. 我已经在项目数据库中添加了DLL。 main sentence even though the connection in the config file add it to the project I'm getting this error. 主语句,即使配置文件中的连接将其添加到项目中,我也收到此错误。
Database dll App.Config file 数据库DLL App.Config文件
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>
Main Project app.config file 主项目的app.config文件
<connectionStrings>
<add name="KgSoftProContext" connectionString="Data Source=KDRGNY\KDRGNY;Initial Catalog=KgSoftPro;Integrated Security=True;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
context file 上下文文件
static KgSoftProContext()
{
Database.SetInitializer<KgSoftProContext>(null);
}
public KgSoftProContext()
: base("name=KgSoftProContext")
{
}
it's been outta control I'm trying to do the problem completely. 我一直试图完全解决这个问题。 the problem is solved. 问题已经解决了。
将连接字符串部分复制到主项目中的.config文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.