CREATE DATABASE permission denied in database 'master' - using Web Deploy, EF Code First, Visual Studio

14,558

Solution 1

I've just come across this problem and I resolved it following the instructions here. Effectively, the "IIS APPPool\DefaultAppPool" user must first be added. While adding it, ensure that as its "Server Roles" it is a "sysadmin".

Solution 2

If you'r running the application from IIS, then IIS APPPOOL\{Your apppool name} is the sql user trying to create the db. If there is no such user in you sql server then create one with the name IIS APPPOOL\{Your apppool name} and give server role dbcreator, public and sysadmin. Now I hope you won't see the error, code first should create the db.

Share:
14,558
niico
Author by

niico

Web Developer with Microsoft Technologies

Updated on June 13, 2022

Comments

  • niico
    niico almost 2 years

    Visual Studio 2012 Express, EF5, Code First Migrations, Web Publish.

    I am doing a web publish from a Windows 8 Laptop to a Windows Server 2008 R2 web server using Web Deploy from Visual Studio 2012.

    The files are uploaded fine. But I get this error: CREATE DATABASE permission denied in database 'master'

    When Code first tries to create the database.

    The Web Publishing wizard uses a windows user to login - that user has db_owner permissions on the master database.

    Exactly what do I need to do to grant CREATE DATABASE permissions? (or see which user tried to do it - the error doesn't report that for some reason?!).

    Thanks.