Software⏱️ 2 min read📅 2026-05-31

How to Fix: CREATE DATABASE permission denied in database 'master' (EF code-first)

SQL Server permission error when creating database.

Quick Answer: Check the SQL Server login credentials and ensure the correct provider is used in the connection string.

The 'CREATE DATABASE permission denied in database 'master'' error occurs when the SQL Server instance is not properly configured or the user account used to connect to the database does not have the necessary permissions.

💡 Why You Are Getting This Error

  • [Cause]

✅ Best Solutions to Fix It

Method 1: Update Connection String

  1. Step 1: Change the connection string to use a different database name, such as 'aspnet-test' instead of 'master', and make sure the user account has the necessary permissions.

Method 2: Grant 'sysadmin' Role

  1. Step 1: Run the SQL command `ALTER ROLE sysadmin ADD MEMBER ;` to grant the user account with the necessary permissions.

✨ Wrapping Up

To avoid this error in the future, ensure that your database connection string is correct and the user account has the necessary permissions. Regularly review and update your SQL Server configuration to prevent similar issues.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions