Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Code First - {"CREATE DATABASE permission denied in database 'master'."}

I just want to quickly spin up the default database in my development environment.

How is the easiest way to get around this problem?

like image 472
user880954 Avatar asked Jan 01 '26 01:01

user880954


1 Answers

I once faced this problem and resolved it. The key is using SQL authentication instead of Windows'. This is the clearest way to specify the default db.

Try connection string in this way:

<add name="MFCConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MFC.mdf;Initial Catalog=MFC;Integrated Security=false;User ID=sa;Password=123"
  providerName="System.Data.SqlClient" />

remember to set default db of sa from master to MFC, and Integrated security = false. BTW, sa is normally disabled, so enable and test it in sql server management studio first.

like image 64
cheny Avatar answered Jan 02 '26 14:01

cheny