Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question
4  
Use a SQL account having CREATE DATABASE rights. –  Raptor May 15 '13 at 9:41
    
@ShivanRaptor It means I've to enable SA account for example ? –  Unforgiven May 15 '13 at 9:45
    
yes. You have to use administrative account –  Raptor May 15 '13 at 10:14
    
You can grant a users/role permission to create a database by doing GRANT CREATE DATABASE TO AnAppUser –  Brian May 15 '13 at 16:41
    
@Brian Is this TSQL Command ? Is this command executable if the user isn't admin on his machine? –  Unforgiven May 15 '13 at 21:40
add comment

migrated from stackoverflow.com May 15 '13 at 22:58

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 3 down vote accepted

You need to execute this T-SQL command using an account that does have administrative rights, such as sa:

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.