question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

permission denied in database 'master'

See original GitHub issue

Hi,

On a shared MSSQLSERVER 2019, where public view any database is denied to all users, Entity Framework returns the following error:

<Message>An error has occurred.</Message>
<ExceptionMessage>CREATE DATABASE permission denied in database 'master'.</ExceptionMessage>
<ExceptionType>System.Data.SqlClient.SqlException</ExceptionType>
<StackTrace> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at

If we give to the user “sysadmin” or “View any database”, the application works, without that, fails.

If we define wrong password, the system returns failed login.

Even with this error, using SMSS, we can login with user and password, database is not visible but if we query the MSSQL.

SELECT name FROM master.dbo.sysdatabases

1 master
2 tempdb
3 MYDATABASE

Based on this, user and password have access and can access to the MYDATABASE but for some reason without sysadmin or see “any database”, the Entity Framework returns that Exception.

Any suggestion to workaround this on a shared environment where user cannot be a sysadmin / dbcreator / etc?

Thank you

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ajcvickerscommented, Nov 17, 2022

This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information.

0reactions
ajcvickerscommented, Nov 17, 2022

@tiagomreis This is EF6, not EF Core. Make sure to disable database initializers.

static MyContext()
{
    Database.SetInitializer<MyContext>(null);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

sql server - CREATE DATABASE permission denied in ...
Go to Database-> Security -> Logins section in object explorer and edit the properties of the user that you want to have create...
Read more >
CREATE DATABASE permission denied in database 'master'
Permissions are granted when the login have the required roles. The role having permission to create, alter and drop database is dbCreator.
Read more >
How to fix "CREATE DATABASE permission denied in ...
If you receive the following error message CREATE DATABASE permission denied in database 'master', check whether the user account has 'dbcreator' access.
Read more >
What should I do if I receive this - create database permission ...
In case of - create database permission denied in database master - The user must be a member of the dbcreator server role...
Read more >
CREATE DATABASE permission denied in ...
Open the Start menu, select All Programs, and open Microsoft SQL Server 2005/2008->Configuration Tools->SQL Server Surface Area Configuration.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found