Babak Saeedi
Babak Saeedi

Reputation: 157

The underlying provider failed on Open in entity framework connection

i use Entity framework in .net 4 and use this connection in project:

<add name="Database1Entities" connectionString="metadata=res://*/Model.Model1.csdl|res://*/Model.Model1.ssdl|res://*/Model.Model1.msl;provider=System.Data.SqlClient;pr  ovider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector  y|\Database1.mdf;initial catalog=Database1;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

and show this error:

The underlying provider failed on Open.

Upvotes: 1

Views: 8866

Answers (2)

Usama Mukhyer
Usama Mukhyer

Reputation: 1

The problem is not in your connection string. This is mostly happen when you are rebuild and clean the project again and again. there is a simple way to solve this problem is that close your local host and wait 2 to 3 minutes. If you face this problem again then close your project and open your project again. Your problem will sort out.

Upvotes: 0

Saman Qaydi
Saman Qaydi

Reputation: 171

I don't know why you get this error but I use this connection string and I don't have any problem. remember the name of the DbContext class and connection string should be same

<add name="MyDB"
     connectionString="Server=127.0.0.1;User ID=sa;Password=password;Database=Database"
     providerName="System.Data.SqlClient"/>

Upvotes: 2

Related Questions