日期:2014-05-16  浏览次数:20457 次

entity framework 4 此操作要求连接到 'MASTER' 数据库错误解决方案
在第一次运行程序时,用Entity Framework进行修改和删除时总会报一次 此操作要求连接到 'master' 数据库错误 
再次修改或者删除就不会出现此错误 
因为Entity Framework 4也是第一次使用  这错误也找了很久 
今天有点时间,就耐着性子去google解决办法
找了很久 最后在一个老外的评论回复里找到解决办法

"This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. Supply an unopened connection."

I had this error and solved it by adding "Persist Security Info=true" to the connection string.

意思是在连接字符串上要加 Persist Security Info=true

Persist Security Info=true 的意思是让.net一直保存着连接密码,默认是为false的

只是不明白 为什么在出现一次错误后 第二次就不会出现 难道出现过错误 .net就自动把密码给保存上了?