我使用的是WPF Windows和ADO.NET EF 6x,VS 2015更新3。 只有在设计时才会出现“无法在应用程序配置文件中找到连接字符串”的错误。
The image at design time 但是当我运行它时,编译时没有错误并且工作完美。 The image at run time
如何解决这个问题?
我的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=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="knightitEntities" connectionString="metadata=res://*/KnightModel.csdl|res://*/KnightModel.ssdl|res://*/KnightModel.msl;provider=System.Data.SqlClient;provider connection string="data source=DESKTOP-ELNOS23;initial catalog=knightit;user id=user;password=password;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<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>
</configuration>