EF を介して SQL データベースにアクセスする WCF サービスの構成についてサポートが必要です。Visual Studio を使用してローカルでサービスを起動すると、サービスは正常に動作しますが、別のサーバーに展開してクライアント アプリケーションからアクセスすると、"{" データベースからプロバイダー情報を取得中にエラーが発生しました。これは、不適切な接続文字列を使用する Entity Framework が原因である可能性があります。内部例外で詳細を確認し、接続文字列が正しいことを確認してください。"}" エラー。
サービスをサーバーに公開する前の接続文字列は次のとおりです。
<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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
</entityFramework>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ECUWebUi-20121116095239;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ECUWebUi-20121116095239.mdf" />
</connectionStrings>
公開後の接続文字列:
<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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=localhost; Integrated Security=SSPI; Initial Catalog=ECUWeb-Staging;User ID=user;Password=password" />
</connectionStrings>
これは、サービス内の EF コンテキストへの呼び出しです。
public RegisterResponse Register(RegisterRequest request)
{
EfDataAccessFactory factory = new EfDataAccessFactory(new DtoMapper());
RegisterResponse response = new RegisterResponse();
if (request.Computer.Exists())
{
factory.ComputerDataAccess.Update(request.Computer);
response.Message = string.Format("{0} is already registered.", request.Computer.Name);
}
else
{
request.Computer = factory.ComputerDataAccess.Insert(request.Computer);
response.Message = string.Format("{0} registered with id: {1}", request.Computer.Name, request.Computer.Id);
}
RegisterInstances(request);
return response;
}
助言がありますか?また、内部例外は null です。