Hubert Solecki
Hubert Solecki

Reputation: 2771

Open: underlying provider failed on Open

I'm facing an issue that I've never encoutered before using Entity Framemork with MySQL connector. I have the simple method core below:

ps_manufacturer manufacturer = null;
using (var context = new afflelou_storeEntities())
{
       var manufacturerList = context.ps_manufacturer.Where(m => m.id_AA_manufacturer == anId).ToList();
       if (manufacturerList.Count > 0)
       {
             manufacturer = manufacturerList.ElementAt(0);
       }
}
return manufacturer;

There is no data in database, so it should returns null. But instead, it throws me that error:

Open: underlying provider failed on Open

I've tried to use firstOrDefault but nothing works... I was thinking that it's a database connection error, but I'm always using a using from my database connexions, so it never happens to have a non closed connexion. Someone has already faced that issue ?

Upvotes: 0

Views: 636

Answers (1)

Renzo Robles
Renzo Robles

Reputation: 714

Definitely is a issue with your string connection, check it! If your credentials are right, so check doing ping to database server.

Upvotes: 1

Related Questions