てぃぐれのプログラマwiki

ワクワクに従う

dotnet ef dbcontext scaffold error: 26 - Error Locating Server/Instance Specified) 【SQL SERVER】

エラーメッセージ

    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 Server is configured
to allow remote connections.
(provider: xxx, error: 26 - Error Locating Server/Instance Specified)

 

コード

dotnet ef dbcontext scaffold "Server=xxx;Database=blazordb;
Trusted_connection=True" Microsoft.EntityFrameworkCore.SqlServer -o Models

 

解決

「Server=」の参照先を間違えていた。

参照個所はVisualStudioのデータべース名のプロパティ > 現在の接続パラメータ >「サーバー」を参照する。

ちなみに「DataBase=」はデータベース名を参照する。

 



 

 error: 40 - Could not open a connection to SQL Server)

error 40でも同様のエラーが起きていると思うので上記確認をしたほうがよいだろう。