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="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\Database1.mdf;initial catalog=Database1;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
and show this error:
The underlying provider failed on Open.
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"/>
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.