Przeszukano google i przy użyciu dostępu do danych biblioteki Enterprise w celu połączenia z bazą danych.Microsoft.Practices.EnterpriseLibrary.Data.DLL ale nie było obsługiwane w kodzie użytkownika
Zainstalowany tylko pakiet dostępu do danych za pomocą https://www.nuget.org/packages/EnterpriseLibrary.Data/.
Po dodane do projektu, mam ustawić konfigurację w następujący sposób
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</configSections>
<dataConfiguration defaultDatabase="dProvider" />
<connectionStrings>
<add name="dProvider" connectionString="server=local;Initial Catalog=n;uid=sa;pwd=pwd"
providerName="System.Data.SqlClient" />
</connectionStrings>
Powołani przez zastosowanie podobnego Poniżej
Database db;
string sqlCommand;
DbCommand dbCommand;
db = DatabaseFactory.CreateDatabase("dProvider"); or DatabaseFactory.CreateDatabase();
Po uruchomieniu aplikacji, mam następujące wyjątek,
{"Database provider factory not set for the static DatabaseFactory. Set a provider factory invoking the DatabaseFactory.SetProviderFactory method or by specifying custom mappings by calling the DatabaseFactory.SetDatabases method."}
Jaki błąd popełniłem? Jak rozwiązać ten problem?