Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6666221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:48:21+00:00 2026-05-26T02:48:21+00:00

I have an Entity Framework based MVC application linked to a SQL server. This

  • 0

I have an Entity Framework based MVC application linked to a SQL server.

This is not a production server, so, I am using Entity Framework Code First and taking advantage of Code First / Dropping the database when the schema changes.

I have the following connection string:

<add name="MyDbContext"
     connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=appdb;User Id=xxx;Password=yyy;"
     providerName="System.Data.SqlClient" />

I had various problems with EF/SQL, in the end, I created a new user with the sysadmin server role, I created the database appdb, set the new users default database to appdb and under User Mapping, I gave the user db_owner permissions (under user and default schema, it says dbo).

Anyway, everything worked as expected after I did this – The database was deleted/recreated with the needed tables.

However, I have now changed my classes. Using DropCreateDatabaseIfModelChanges causes a yellow screen with Unable to login to SQL Server with user:xxx error, and SQL server logging shows Login failed for user 'xxx'. Reason: Password did not match that for the login provided. [CLIENT: <local machine>]

If I launch the application on debug, it shows the following:

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.

If I change from DropCreateDatabaseIfModelChanges to DropCreateDatabaseAlways – everything works as expected…. I can then change back, and continue using the application without problems.

I really do not understand this and was wondering if anyone knows what is going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:48:21+00:00Added an answer on May 26, 2026 at 2:48 am

    Try to add Persist Security Info=True to your connection string.

    Edit:

    Setting Persist security info to true allows database connection maintaining sensitive user information = password. I don’t know what magic EF does when dropping and recreating database but it most probably resets connection state and requires new authentication on opened connection. Without persisting security info opened connection cannot authenticate user again because it doesn’t know his password.

    Btw. you can also try to download EFv4.1 Update 1 or better EFv4.2. I think it should fix this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First some brief background: I have an existing ASP.NET MVC 1 application using Entity
The setup: (using Asp.Net MVC 2 RC, Entity Framework, SQL Server, VS2008) My buddy
I'm using Entity Framework Code First to generated my database, so I have an
I have an app using the ADO.NET entity framework (the VS2008 version, not the
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
We have a great software foundation based on Microsoft MVC 2, Entity Framework 4,
I have started using the entity framework for a web application and would like
Despite a few hiccups and a few workarounds, my MVC based Entity Framework (Code
I have strange problem with disposing entity framework connection in asp.net mvc application. I
I am using Linq and the Entity Framework. I have a Page Entity, that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.