asp.net-mvc – Permission to create Database denied by 'master' database

Question:

I'm trying to migrate the database created automatically by Identity to control user authentication and I get this error:

CREATE DATABASE permission denied in database 'master'.

My connection string looks like this:

<add name="DefaultConnection" connectionString="Data Source=LPG-11;Initial Catalog=LPGPonto.Models.LPGPontoContext;Integrated Security=True;user id=sa;password=xxxxxx" providerName="System.Data.SqlClient" />

With this same user (sa – who is the Owner of the master database) and password I can create a database normally by Management Studio, however when I try to create by migrating from Visual Studio it gives this error. The username and password are correct, user "sa" has permission to everything in SQL Server. What can it be?

Answer:

I managed to create. The error was in my connection string, in the Security User parameter. I changed it like this and it worked:

<add name="DefaultConnection" connectionString="Data Source=LPG-11;Initial Catalog=LPGPonto.Models.LPGPontoContext;Integrated Security=False;user id=sa;password=xxxxxx" providerName="System.Data.SqlClient" />
Scroll to Top