snippetsqlMinor
CREATE DATABASE permission denied in database 'master'
Viewed 0 times
createpermissiondenieddatabasemaster
Problem
I've developed a desktop application using WPF and Entity Framework code-first.
In my application the user can create multiple databases at run-time.
But Entity Framework can't create database if the user isn't admin on his machine.
I need to find a solution that could be done with coding. Management Studio is not installed on the user's machine.
What do you suggest?
In my application the user can create multiple databases at run-time.
But Entity Framework can't create database if the user isn't admin on his machine.
I need to find a solution that could be done with coding. Management Studio is not installed on the user's machine.
What do you suggest?
Solution
You need to execute this T-SQL command using an account that does have administrative rights, such as sa:
Replace
USE master;
EXECUTE sp_addsrvrolemember @loginame = N'YourAppUserLogin', @rolename = N'dbcreator';Replace
YourAppUserLogin with the login the application user uses to connect to the database.Code Snippets
USE master;
EXECUTE sp_addsrvrolemember @loginame = N'YourAppUserLogin', @rolename = N'dbcreator';Context
StackExchange Database Administrators Q#42299, answer score: 5
Revisions (0)
No revisions yet.