Reputation: 7818
I have suddenly started getting an error in my application.
The error is:
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.
Nothing has changed in the code - and database access is fine throughout the rest of the code.
It stops on this line:
var filteredContacts = dc.EAContactLists.Where(o => teams.Contains(o.Team)).ToList();
I am lost on this one.
Upvotes: 31
Views: 40947
Reputation: 1
I Used this config in my code: Integrated Security=true;
as this:
<connectionStrings>
<add name="MyContext" connectionString="Data Source=.;Initial Catalog = MyDatabase_DB; Integrated Security=true; MultipleActiveResultSets=true" providerName="System.Data.SqlClient" />
</connectionStrings>
and it worked.
Upvotes: -1
Reputation: 1
Had this same issue. Found out that in my connection string, where it says "Persist Security Info = True;"
, I was missing the semi-colon at the end. Added the semi-colon and everything worked
Upvotes: -1
Reputation: 2414
I am so stupid. I faced the same error and then I realized that I was running the update-database -verbose command in Package Manager Console in Release mode when I hadn't configured the transformations for release mode.
Here is the connectionstring format that worked for me in Debug mode.
Password=dumbeldore;Persist Security Info=True;User ID=johnmcclain;Initial Catalog=DB_diehard400;Data Source=killthatbill;
Upvotes: 0
Reputation: 41
If you are working on windows authentication :
For user authentication:
Upvotes: 3
Reputation: 571
Add Integrated Security=True
for windows authentication.This worked for me.
Upvotes: 9
Reputation: 149
Make sure you aren't running Fiddler. Temporarily disabling traffic capture with F12 resolved the issue for me.
Upvotes: -1
Reputation: 237
This error happened to me and none of the above worked. Embarrassingly, I realised that I had missed out a semi-colon from the connection string. Might be useful...
Upvotes: 13
Reputation: 2793
Try setting Persist Security Info = True
in your connection string.
Hope this helps.
Upvotes: 47
Reputation: 256
I had this issue and in my case resolved it by adding "Integrated Security=True" to the connection string. This only applies if you're connecting to the DB using Windows Authentication. Hope it helps.
Upvotes: 17
Reputation: 293
Hello actually this problem persist if you are trying to make changes in the schema like creating the table or altering some object...
And you don't have privileges to do that..
If you are working with MVC and your database already exit in the server than this problem can be solved with the code
Database.SetInitializer<EmployeeContext>(null);
just add this code in the Global.asax file in the application_start Event method.
Upvotes: 3