My application has a DAL layer with a working local database. I have tests interacting with the db and they work fine.
I also have a wcf service that uses the functions provided by my DAL. However, when the client application calls the service, no data gets retrieved. Instead, I get an exception:
Message = "The underlying provider failed on Open."
"System.Data.Entity"
StackTrace = "at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)\\r\\n ...
With an inner exception:
"Unable to connect to any of the specified MySQL hosts."
{"No such host is known"}
" at MySql.Data.MySqlClient.NativeDriver.Open()\\r\\n at MySql.Data.MySqlClient.Driver.Open()\\r\\n at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)\\r\\n at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()\\r\\n at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()\\r\\n at MySql.Data.MySqlClient.MySqlPool.GetConnection()\\r\\n at MySql.Data.MySqlClient.MySqlConnection.Open()\\r\\n at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)"
I verified that my connection string is the same as what my tests use.
<add name="loansEntities" connectionString="metadata=res://*/LoansDbModel.csdl|res://*/LoansDbModel.ssdl|res://*/LoansDbModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost:3306;User Id=root;password=123456;database=dbname;Persist Security Info=True"" providerName="System.Data.EntityClient"/>
The database is a local mysql database, the user and database both exist. The services are also local, running in IIS Express.
Why am I getting this exception?
This could be due to several reasons please check below points:
System.Data.SqlClient
in your connection then change it to System.Data.Odbc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.