I created a Winforms application for Windows with local database using Entity Framework.
On my pc the application works fine; but when I created SETUP
and install it on another machine, I get the following error:
See the end of this post for details on invoking debugging
just-in-time (JIT) instead of this dialog.************** Exception text **************
System.Data.Entity.Core.EntityException: The underlying provider failed on Open.
System.Data.SqlClient.SqlException: A network related or instance specific error occurred while establishing a connection to SQL Server. The server cannot be found or is not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error locating the specified server / instance)to System.Data.SqlClient.SqlInternalConnectionTds..ctor (DbConnectionPoolIdentity identity, sqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, newPassword String, SecureString newSecurePassword, Boolean redirectedUserInstance, sqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool accessToken String, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection (DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection (DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject (DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest (DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
This is my app.config
:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<connectionStrings>
<add name="Db_EleveBookEntities"
connectionString="metadata=res://*/EntityModelEB3.csdl|res://*/EntityModelEB3.ssdl|res://*/EntityModelEB3.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename= |DataDirectory|\EleveBookLocaleDB3.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
<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>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Fozzy.Object" publicKeyToken="da510636ee0727d5" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.5585.19816" newVersion="1.1.5585.19816" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>