Solved

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

Posted on 2016-08-22
7
31 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

746 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

12 Experts available now in Live!

Get 1:1 Help Now