The underlying provider failed on Open in entity framework connection

左心房为你撑大大i 提交于 2019-12-08 04:23:30

问题


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.


回答1:


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"/>



来源:https://stackoverflow.com/questions/18161627/the-underlying-provider-failed-on-open-in-entity-framework-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!