
###前提・実現したいこと
Entity Framework 6を使用したコードファースト・マイグレーションで、
パッケージマネージャコンソールから、SQL Serverに対してUpdate-Databaseを実行時に、
SqlException(SQL Network Interfaces, error: 26)が発生し、作業が失敗してしまいます。
以下、実行したコマンド
PM> Update-Database
以前は問題なくマイグレーションできていた認識ですが、
Windows10更新プログラムの適用&再起動以後、上記現象が発生しました。
エラーメッセージから、接続文字列/SQL Serverの構成に問題があると考えております。ご助言いただけると幸いです。
プロジェクト構成
- Visual Studio Professional 2017
- ASP.NET MVC5.2.3
- .NET Framework 4.6.1
- EntityFramework 6.1.3
- ASP.NET Identity 2.2.1
- IIS10(Expressではありません)
- SQL Server Express 2014
SQL Serverについては、ローカルDBにWindows認証で接続しております。
Web.config上の接続文字列は以下の通りです。(Web.Config全文は文末に記載)
xml
1<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS2014;Initial Catalog=hogefuga;Integrated Security=True;" providerName="System.Data.SqlClient" />
####確認したこと
サーバエクスプローラから以下を実行
データ接続>接続の追加
- データソース:Microsoft SQL Server (SqlClient)
- サーバ名:.\SQLEXPRESS2014
- 認証:Windows認証
- データベース名:hogefuga
--->接続成功
SSMSから同様に以下で接続
- サーバ名:.\SQLEXPRESS2014
- 認証:Windows認証
--->接続成功
ローカルIISにWebブラウザから接続
ApplicationUserによるログイン
. --->正常に成功
既存データモデルの登録(Insert)
. --->正常に成功
###発生している問題・エラーメッセージ
文字数規制にかかってしまったため、一部省略しております。
ターゲット データベースに適用されている SQL ステートメントを表示するには、'-Verbose' フラグを指定します。 System.Data.SqlClient.SqlException (0x80131904): SQL Server への接続を確立しているときにネットワーク関連またはインスタンス固有のエラーが発生しました。サーバーが見つからないかアクセスできません。インスタンス名が正しいこと、および SQL Server がリモート接続を許可するように構成されていることを確認してください。 (provider: SQL Network Interfaces, error: 26 - 指定されたサーバーまたはインスタンスの位置を特定しているときにエラーが発生しました) 場所 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) 場所 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 場所 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) (中略) 場所 System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) 場所 System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration) 場所 System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run() 場所 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 場所 System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) 場所 System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) 場所 System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force) 場所 System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0() 場所 System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) ClientConnectionId:00000000-0000-0000-0000-000000000000 Error Number: -1、State: 0、Class: 20 SQL Server への接続を確立しているときにネットワーク関連またはインスタンス固有のエラーが発生しました。サーバーが見つからないかアクセスできません。インスタンス名が正しいこと、および SQL Server がリモート接続を許可するように構成されていることを確認してください。 (provider: SQL Network Interfaces, error: 26 - 指定されたサーバーまたはインスタンスの位置を特定しているときにエラーが発生しました)
###Web.Config全文
xml
1<configuration> 2 <configSections> 3 <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 4 <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 5 </configSections> 6 <connectionStrings> 7 <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS2014;Initial Catalog=jslmember;Integrated Security=True;" providerName="System.Data.SqlClient" /> 8 </connectionStrings> 9 <appSettings> 10 <add key="webpages:Version" value="3.0.0.0" /> 11 <add key="webpages:Enabled" value="false" /> 12 <add key="ClientValidationEnabled" value="true" /> 13 <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 14 </appSettings> 15 <system.web> 16 <authentication mode="None" /> 17 <compilation debug="true" defaultLanguage="c#" targetFramework="4.6.1" /> 18 <httpRuntime targetFramework="4.6.1" /> 19 <httpModules> 20 <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> 21 </httpModules> 22 <globalization fileEncoding="utf-8" /> 23 </system.web> 24 <system.webServer> 25 <modules> 26 <remove name="FormsAuthentication" /> 27 <remove name="ApplicationInsightsWebTracking" /> 28 <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> 29 </modules> 30 <handlers> 31 <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 32 <remove name="OPTIONSVerbHandler" /> 33 <remove name="TRACEVerbHandler" /> 34 <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 35 </handlers> 36 <validation validateIntegratedModeConfiguration="false" /> 37 </system.webServer> 38 <runtime> 39 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 40 <dependentAssembly> 41 <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" /> 42 <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 43 </dependentAssembly> 44 <dependentAssembly> 45 <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" /> 46 <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 47 </dependentAssembly> 48 <dependentAssembly> 49 <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" /> 50 <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 51 </dependentAssembly> 52 <dependentAssembly> 53 <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" /> 54 <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 55 </dependentAssembly> 56 <dependentAssembly> 57 <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> 58 <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 59 </dependentAssembly> 60 <dependentAssembly> 61 <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /> 62 <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> 63 </dependentAssembly> 64 <dependentAssembly> 65 <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> 66 <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> 67 </dependentAssembly> 68 <dependentAssembly> 69 <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> 70 <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 71 </dependentAssembly> 72 <dependentAssembly> 73 <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 74 <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> 75 </dependentAssembly> 76 <dependentAssembly> 77 <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> 78 <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 79 </dependentAssembly> 80 </assemblyBinding> 81 </runtime> 82 <entityFramework> 83 <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 84 <parameters> 85 <parameter value="mssqllocaldb" /> 86 </parameters> 87 </defaultConnectionFactory> 88 <providers> 89 <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 90 </providers> 91 </entityFramework> 92 <system.codedom> 93 <compilers> 94 <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> 95 <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> 96 </compilers> 97 </system.codedom> 98</configuration>
回答1件
あなたの回答
tips
プレビュー