简体   繁体   中英

No connection string named 'KgSoftProContext' could be found in the application config file

I've added the DLL in my project database. 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

<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

<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文件中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM