2017-10-17 7 views
0

localdbの代わりにSQL Server 2016を使用しようとしています。私はv13.0mssqllocaldbからweb.configファイルでそれを変更しようとすると、それは私に次のエラーを与える:Entity Frameworkの接続文字列をlocalDBからMicrosoft SQL Serverに変更します

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

+1

あなたは何のSQL Server 2016の**版**をインストールしたのですか?インストール時にインスタンス名を指定しましたか? SQL Server 2016 ** Express **はデフォルトで '。\ SQLEXPRESS'としてインストールされますが、他のエディションは通常、デフォルトの名前のないインスタンスとしてインストールされます(' .'または '(local)'を使用してサーバー/インスタンス名) –

+0

エンタープライズエディションと何も指定していません –

+0

したがって、接続文字列は 'Data Source =(local);初期カタログ=(あなたのデータベース名);統合セキュリティ= SSPI;またはそのようなもの - あなたが使っているものを私たちに(あなたの質問を編集/更新して)見せてもらえますか? –

答えて

1

あなたはMSDN: Entity Framework Config File Settings

web.configファイルで設定について読むことができますかもしれない:

<?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> 
-1

[IIExpress] [1]

I believe since .netFramework4 IIExpress has been the default Db. 
Prior to that I believe localIS was. The Image below shows how to change 
to IIExpress if required. This tutorial will explain it better. 

https://www.youtube.com/watch?v=k5RKfOEpOGk&index=9&list=PL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo

[1]: https://i.stack.imgur.com/yP3cj.png 

Here is a very good tutorial to help write the ADO.net code 

https://www.youtube.com/watch?v=aoFDyt8oG0k&list=PL6n9fhu94yhX5dzHunAI2t4kE0kOuv4D7

関連する問題