2016-07-26 36 views
0

データベースへの接続を処理する別のdllがあり、モデルとapiコンテキストが保持されています。 app.configファイルには、web.configファイルのような「働き」と私は Entity FrameworkのDLLがデータベースに接続できません

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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

だから、私は別の、より伝統的なMVC web.configファイルから接続文字列をコピーし、次のエラーを得続けると、エラーが引き続き発生しかし、接続の詳細を保持しています。奇妙なことに

、次のような作品:

update-database -verbose 

マイapp.configは、次の接続文字列があります。私が言うように、この、それに

<add name="DefaultConnection" 
    connectionString="data source=(LocalDb)\v11.0;initial catalog=APIEntities-01;persist security info=True; Integrated Security=SSPI;MultipleActiveResultSets=True" 
    providerName="System.Data.SqlClient" /> 

dbContextポイント

public ApiContext() : base("DefaultConnection") 
{ 
} 

を従来のMVCで動作しますweb.config、しかしEntity Frameworkなどを参照するdllを使用すると、データベースを見つけることができないようです。助言がありますか?

私が原因で、接続文字列と仮定EF 6

答えて

1

"データソース=(LocalDb)の\ v11.0;初期カタログ= APIEntities-01" は、あなたのPCのローカルパスです。使用する必要がある実際のSQL Serverを提供する必要があります。 SQL Serverが開くことができなかったいくつかの倍のhapenに

Change default location of LocalDb

0

:これを参照してください。その後、SQL Serverの設定を開いて、(SQL Server Services)を選択して、停止状態または手動状態を確認します。次に右クリックして起動します。問題が解決されます。

関連する問題