niico
niico

Reputation: 12749

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

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.

Upvotes: 2

Views: 15376

Answers (2)

BlueSky
BlueSky

Reputation: 11

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.

Upvotes: 1

DavidS
DavidS

Reputation: 2283

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".

Upvotes: 11

Related Questions