CREATE DATABASE permission denied in database 'master'

Tags: mvc, mvc4, entity framework, ef, code first, sql, database

 

So I was trying to play with MVC 4 along with entity framework(EF) and just when I was getting started  and I got this error. 

The error itself is pretty explanatory. It's saying, that the visual studio is unable to create the database on my behalf with the default credentials with which I am logged in. I am guessing it wasn't even able to create the database and hence using 'master' database?? I don't know... I don't know if my local sql express is corrupted or what..

Anyway, I resolved it in following way:

  • Created a database in SQL Server 2008.
  • Add a user to that database and make sure to give the necessary permissions. I just gave all possible permission since I am just playing but you probably don’t want to do that unless you are playing with your local copy.    
  • image
  • Now use that database in connection string in the web.config of the project. Please make sure to add the connection string to the web.config of the project not the one under Views.
  • Looks as follows:
    • image
  • Also make sure to use the same name while creating the context class.
  • image

 

Hope it helped!

1 Comment

Add a Comment

Recent Posts