Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2016-08-22
7
Medium Priority
?
243 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
  • 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 45

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

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

Assisted Solution

by:Brian Crowe
Brian Crowe earned 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

876 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