Solved

On the deployed site I get the following error message CREATE DATABASE permission denied in database 'master'.

Posted on 2016-08-22
7
107 Views
Last Modified: 2016-08-27
On the deployed site I get the following error message "CREATE DATABASE permission denied in database 'master'." when the db already exists. I can connect to the database with no problem from MS SQL Server Management Suite but when the web application tries to access the database I get the above error. I use the same login credential from MS SQL MS as from the app. Hosted on godaddy. My connection strings are:
<connectionStrings>
    <add name="csCommunityCrier" connectionString="Data Source=198.71.225.113;Initial Catalog=dbCommunityCrier.mdf;Integrated Security=False;User ID=*******;Password=*******;Connect Timeout=15" providerName="System.Data.SqlClient" />
    <add name="CommunityCrierEntities" connectionString="metadata=res://*/App_Code.CommunityCrierModel.csdl|res://*/App_Code.CommunityCrierModel.ssdl|res://*/App_Code.CommunityCrierModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=198.71.225.113;Initial Catalog=dbCommunityCrier.mdf;Integrated Security=False;User ID=**********;Password=********!;Connect Timeout=15;MultipleActiveResultSets=TrueApp=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

Open in new window

0
Comment
Question by:OhioWoodWright
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 41765718
The issue is not with your connection string but with what you are trying to do with it.  Somewhere you are issuing a CREATE DATABASE command for a database that already exists.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41765734
First: as already mentioned - please read the error message you get and then think about it, not assume the problem is something totally different.

Second: On the deployed site....  Does that mean it works perfectly on your development machine?
0
 

Author Comment

by:OhioWoodWright
ID: 41765735
No place in my code am I issuing a CREATE DATABASE command. Ive done a global search and the stack trace is pointing to EF maybe?

Stack Trace:
[SqlException (0x80131904): CREATE DATABASE permission denied in database 'master'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2441746
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736520
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +628
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +3731
   System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +940
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +272
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +280
   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c) +10
   System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
   System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +356
   System.Data.Entity.SqlServer.<>c__DisplayClass1a.<CreateDatabaseFromScript>b__19(DbConnection conn) +119
   System.Data.Entity.SqlServer.<>c__DisplayClass33.<UsingConnection>b__32() +443
   System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +10
   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +189
   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +78
   System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +175
   System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +557
   System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable`1 commandTimeout, DbConnection sqlConnection, String createDatabaseScript) +86
   System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +164
   System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection) +76
   System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134
   System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection) +119
   System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +142
   System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78
   System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext) +89
   System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState) +116
   System.Data.Entity.Database.Create(DatabaseExistenceState existenceState) +218
   System.Web.Providers.ModelHelper.EnsureDatabaseCreated(DbContext db) +80
   System.Web.Providers.ModelHelper.CreateMembershipContext(ConnectionStringSettings setting) +86
   System.Web.Providers.DefaultMembershipProvider.ValidateUser(String username, String password) +99
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +59
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +113
   System.Web.UI.WebControls.Login.AttemptLogin() +119
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +75
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +114
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +164
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3562

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:OhioWoodWright
ID: 41765737
Yes it works perfectly on my site
0
 
LVL 34

Assisted Solution

by:Brian Crowe
Brian Crowe earned 500 total points
ID: 41765746
Apparently I was wrong.  It may in fact be a connectionstring issue related to Entity Framework.

I found the following reference which hopefully will help...

According to this question, it may be an issue related to the class name and database name not matching, which would cause EF to try to create a new database.

http://stackoverflow.com/questions/28492201/ef-code-first-create-database-permission-denied-in-database-master-error
0
 

Accepted Solution

by:
OhioWoodWright earned 0 total points
ID: 41765758
Got it. It was a hard to catch boneheaded error in the connection string. I left the file extension on the db name. Works fine now. Thanks for you help, may have taken me more hours of research for a stupid typo.
0
 

Author Closing Comment

by:OhioWoodWright
ID: 41772833
was my mistake - typo
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question