Solved

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

Posted on 2016-08-22
7
37 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 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now