0

I'm trying to use SQL Server 2016 instead of localdb. When I try to change it in the web.config file from mssqllocaldb to v13.0 it gives me the following error:

An exception of type 'System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code.

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL

4
  • 1
    What edition of SQL Server 2016 did you install? And did you specify an instance name during installation? The SQL Server 2016 Express is by default installed as .\SQLEXPRESS, while other editions are typically installed as default, unnamed instances (which you can access using . or (local) as your server/instance name) Commented Oct 17, 2017 at 7:44
  • Enterprise edition and didn't specify anything Commented Oct 17, 2017 at 8:19
  • So then your connection string should be something like Data Source=(local); Initial Catalog=(your db name); Integrated Security=SSPI; or something like that - can you please show us (by editing/updating your question) what you're using?? Commented Oct 17, 2017 at 8:27
  • "What is wrong with this connection string I'm not showing"? Commented Oct 18, 2017 at 8:35

1 Answer 1

1

You can read about the configuration at MSDN: Entity Framework Config File Settings

An example web.config could be:

<?xml version="1.0"?>
<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="MyConnectionString" connectionString="Data Source=MySqlServerInstance;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </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>

</configuration>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.