CREATE DATABASE is permitted in the "master" database. error in MVC 4 application

After deploying my MVC 4 application, I try to register the user, get this error:

Granting CREATE DATABASE permission in the "master" database.

Connection string:

<add name="Market" providerName="System.Data.SqlClient" connectionString="Data Source=endine.arvixe.com; Initial Catalog=Market; Uid=mylogin; Password=mypass; MultipleActiveResultSets=true; " /> 

And DbContext:

 public class Market: DbContext { public Market() { Database.SetInitializer<Market>(new MarketInitializer()); } } public class MarketInitializer: DropCreateDatabaseIfModelChanges<Market> { protected override void Seed(Market context) { base.Seed(context); } } 

I accessed the database using SQL Management Studio with the same mylogin and mypass , created the Market database with a script. But the site cannot access the database.

How can I find the reason?

+4
source share
2 answers

the problem is this code snippet DropCreateDatabaseIfModelChanges<Market>

 public class MarketInitializer: DropCreateDatabaseIfModelChanges<Market> { protected override void Seed(Market context) { base.Seed(context); } } 

At some point, the model has changed, so it tries to reset the database and recreate it

+1
source

Sometimes this happens because you do not have the sysadmin role on the local instance of SQL Server. I found a useful article where you can download the script command and install it. You will be prompted with the name SQLEXPRESS or the name of the instance, you can simply write "SQLEXPRESS" and enter. This is it. It will add you to the sysadmin server role of the local server.

Download command: http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=addselftosqlsysadmin&DownloadId=9198

Please let me know if this does not work for you.

+1
source

Source: https://habr.com/ru/post/1497013/


All Articles